All summary points are for reference only and are not guaranteed to be completely correct
1. The difference between a reference and a pointer
① references must be initialized, pointers can not be initialized
② reference cannot be null, pointer can be empty (wild pointer)
The value of the ③ reference binding cannot be changed, and the pointer can
④ cannot define a reference array, you can define an array of pointers
Recommendation: Use references as much as possible in C + +, rather than pointers, because they are prone to wild pointers, prone to segment errors, and so on.
2. How the function overloads
① function name is the same, the number of parameters is different
② function names are the same, parameter types are different
③ function name is the same, parameter order is different
④ function names are the same, const-modified constant functions and ordinary member functions form overloads
3. Principle of function overloading
The C + + compiler implements overloading by changing the name of the function to reflect the parameter table information in the new function name.
We can compile a compilation file to see the associated overloaded functions.
such as: void Show (int i, int j) {}
_z4showii; <----A new name after the change of name.
4 The number of strings that represent the function name. II is the first letter of the two int to go.
void Show (int i, double j) {}
_z4showid;<----New name after the change of name
4. The difference between const and define
Const-defined constants, which are allocated in size, can be calculated with sizeof
Define defined constants, replace only
5. Static function
Static modifies local variables, and the life cycle becomes longer.
Static modifies global variables, which are part of the current file and prevent other file references.
static modifier function, life cycle becomes longer
The static modifier class member function, without the this pointer, belongs to the entire class and not to a single object.
Static member variables, which must be defined separately outside of the class
Format: Data type class Name:: static member variable = initial value
6. Include<> and include "" Difference
Indlude<> in the system directory to find the relevant files
Include "" In the current directory to find relevant files
7. Self increment and decrement operator
Prefix increment/decrement operator: The value of the expression is increased or decreased, and the value after increment or decrement is returned.
Postfix increment/decrement operator: The value of the expression is increased or decreased by the previous value, and the previous copy is returned
Not to be continued ...
C + + Interview Summary