1. The difference between a reference and a pointer
1) When the reference is created, it needs to be initialized, and the pointer can wait until it is initialized at any time.
2) The reference cannot point to null, and the pointer can point to NULL
3) After the reference is initialized, it can no longer be bound to other objects, and after the pointer is initialized, it is possible to change the object he points to
For the understanding of article 3rd:
int m=90;
int &n=m;
int b=99;
N=b;
b=999;
The cout<<n<<endl;//result is 99 instead of 999, because the second time the reference n is not bound to B
2. Object-oriented features
Encapsulation, inheritance, polymorphism
Encapsulation: Enhanced security and simplified programming, where users do not need to know the specifics of the implementation, as long as the members of the class are used through external excuses and specific access rights
Inheritance: You can use all of the features of an existing class, and inheritance allows one object to use the properties and methods of another object directly
Polymorphic: Enables the ability to use a base-class pointer to point to objects of different classes, performing the same operation differently depending on the referenced object
3. C + + three ways of inheriting
Public inheritance: base class members maintain their own access rights, public in subclasses is still public,proctected in subclasses still protected, base class private members are not visible in subclasses
Protect inheritance: Public and protected members in base class members become protected members, and base class private members are not visible in subclasses
Private inheritance: Public and protected members in base class members become private, and base class private members are not visible in subclasses
4. The difference between class and struct
Class default is private,struct default is public
5. polymorphic
Polymorphic Simple description: One interface, multiple implementations
Main role: Improve the reusability of the program, streamline the code writing
6, overload, overwrite (override), hide
Overloading: The same function name, different parameter types (different parameter types, different parameter numbers, different parameter order "parameter types must not be the same"), cannot do it by accessing permissions, returning types, throwing exceptions for overloading
Overwrite (override): The base class has the virtual keyword, the function name of the derived class and the base class is the same, the parameter type is the same, and the return type is the same
Hidden: a) If the function name and parameter type of the derived class and base class are the same, but the base class does not have the virtual keyword, the function of the base class is hidden B) if the function of the derived class and the base class have the same function name, but the parameter types are different, regardless
If the base class has the virtual keyword, the functions of the base class are hidden. Another understanding of ======== for hiding is that, in addition to the same function name, the condition that does not satisfy the overlay is hidden.
C + + face question