1. In C + +, operators that cannot be overloaded are:
- sizeof
- . Member operators
- . * Member pointer operator
- :: Scope operator
- ? : conditional operator
2. C + + language polymorphism: Compile-time polymorphism and run-time polymorphism:
- Compile-time polymorphism can be implemented by function overloading and template;
- Runtime polymorphism can be realized by virtual function;
- The implementation of the runtime polymorphism mechanism is called dynamic binding;
3. In C + +, the header file references the problem:
- #include <> compiler searches the system directory only and does not search the local directory. For example, if you write a header file yourself, you can make a mistake with # include <>.
- #inlude "" First searches the local directory, if the local directory does not search the system directory;
- The system files can be placed in the current directory and changed to "" can be used as a priority;
4. Set A, B, C, D, M, n are int variables, and a=5, B=6, c=7, D=8, m=2, n=2, then the logical expression (m=a>b) && (n=c>d) operation, the value of n is?
Parsing: This topic examines operator precedence and && usage rules, first = priority is lower than judgment <, there is false on the left side of m=0,&&, then the right side is not executed, so the value of n does not change to 2;
5. Overloaded function refers to the same function name can correspond to the implementation of multiple functions, the compiler will automatically call the corresponding function according to the number of parameters, parameter types, and Note that the function return value type cannot be used as an overloaded judgment condition .
6. Operator overloading Rules:
- Friend function overloaded operator, because there is no this pointer to the object, so the number of parameters remains the same as the original, the parameter list is 1, the description is 1 yuan, the 2 description is 2 yuan;
- member function overload, the argument list is empty, is a unary, the parameter list is 1, is 2 yuan;
7. Circular statement issues:
- while (condition) is false, the loop body does not execute;
- Do while (), the loop body is executed at least once;
- Continue can only appear inside the for/while/do while loop, or inside statements and blocks nested within such loops, and cannot be used in a separate switch continue;
- The break is used to terminate the loop statement closest to it;
8. Constructor Problems:
- There is no return value for either the default constructor or the copy constructor;
- The parameters of the copy constructor can make one or more, but the first must be the reference object of the class from the left;
- If the copy constructor is not declared in the class definition, the compiler will automatically generate a default copy constructor, but it will not be a protected member of the class;
- Another object can be used as the initial value of the object by copying the function;
Basic knowledge of C + + easy to summarize (backlog)