1. Object-oriented programming has 4 main features: Abstraction, inheritance, encapsulation, polymorphism.
2. Relationships between classes and classes: Include relationships, use relationships, and inheritance relationships.
3. Important Notes on inheritance:
Subclasses have all member variables and member functions of the parent class;
Subclasses can have member methods and properties that the parent class does not have;
Subclass is a special kind of parent class;
The subclass object can be used as the parent class object;
4. The type compatibility principle in inheritance:
The compatibility principle refers to the use of derived class objects wherever the base class is needed, and all members outside the constructor and destructor in the base class are obtained through the public inheritance derived class;
In this way, the derived class has all the functions of the base class, and the derived class can solve the problem that the base class can solve.
4. In the case of inheritance and composition mashup, the order of the constructors and destructors is called:
Call the ancestor's constructor first, call the constructor of the parent class, call the constructor of the member class object, and finally call your own constructor.
Call your own destructor first, call the destructor of the Member class object, call the parent class, and then call the ancestor's destructor.
5. member variables and member functions with the same name in inheritance
In the test function to modify/Invoke the same name member variable, member function, by default, the child class is modified;
6. The Static keyword in inheritance
A static member defined by a base class, shared by all derived classes;
The access control of static members still follows the principle of access control inherited by ordinary members;
A static member in a class is declared in a class without allocating memory, and must be allocated at the same time as the external initialization of the class;
The constructor definition should be defined as public access attribute except in singleton mode;
7. Multiple Inheritance: member variables/attributes that inherit several classes at the same time
Multi-Inheritance ambiguity: Virtual inheritance is implemented by virtual keyword to solve the two semantics of inheritance.
C + + Object-oriented inheritance