Experience with C ++

zhaozj2021-02-12  137

Studying C , I used C , I spent a month, I spent a month, I learned C language, and later, I didn't have to go to C , I felt very simple, I learned for a week. I don't think that on the basis of C language, I added a class, I have worked more than a year, and I used it, I really found myself a frog. I used to read all the VC books, in fact, now I found VC! = C , VC is just a programming environment. C is a language. The essence of C in the object-oriented thought, why can I define a class, how to inherit one. It is said that it is object-oriented analysis, object-oriented design, which is OOA / OOD, C complicated in its range, because we work often only use it. For example, we rarely use templates, very little use of senior applications, in fact, to say that our level is not enough, everyone can see if the Loki library may know how much Template has much power. I personally think that Template, like virtual functions, belong to a polymorphism, but the virtual function is through the pointer, implementation, time to analyze, and Template is the compile period analysis, I think it's a macro definition, However, more advanced. There is also a problem, C compiler actually made a lot of things for our code. If we don't know, then, it will often have an error, we should always remember such a sentence: "General is often bad, not suitable for engineering." For example: Why is the function overload? In fact, C is like this to implement the name of the function, such as Class A {show (int A, INT B); show (float a);}; actually, it is internally corresponding: pseudo code: show_int_int (int A, int b, void * this); show_float (float a, void * this); (Everyone thinks about why there will be a THIS pointer) This, natural, show () has no problem, from this It is seen that the internal implementation is just a function name to enable the function name to achieve the function name, and the return value is the same, the number of parameters is the same, the type corresponds, the return value is different. The two functions cannot form an overload, and the compilation error will occur. (We can think about why the return value is not entered in the function name. If there is only two functions return values, such as the following: Class B {public: int Print (int A); void print (int a);} if If you use the return value to the function name, then they should be able to constitute an overload. When you call, B A; A.Print (20); the compiler knows that it is called that function.

转载请注明原文地址:https://www.9cbs.com/read-6234.html

New Post(0)