//clause 32: Determine your public inheritance mold out is-a relationship//1.public inheritance implies a is-a relationship, and the methods that apply to the base class can be used on derived classes. //Article 33: Avoid hiding the inherited name//1. In the public inheritance system, the relationship between the derived class and the base class is is-a, so the non-virtual functions of the base class should not be hidden in the derived class. //2. In order to overload a non-virtual function of a base class in a derived class, you can use a using declaration or display a non-virtual function that calls the base class in a function of a derived class. //Article 34: Differentiating between interface inheritance and implementation inheritance//1. Interface inheritance differs from implementation inheritance. Under the public inheritance system, derived classes always inherit the interface of the base class. //2. Pure virtual functions Specify interface inheritance only. //3. The general virtual function specifies interface inheritance and default implementation inheritance. //4. Non-virtual functions specify interface inheritance and enforce inheritance. (as described in clause 33, do not hide non-virtual functions of the base class in a derived class in public inheritance)//Article 38: By compounding the mold out of the has-a or according to something to achieve//clause 39: Use private inheritance wisely and cautiously//1. Private inheritance is highly likely to be an orthodox design strategy when one of the classes needs to access the protected members of another class, or when a virtual function needs to be redefined, when confronted with two classes that do not have a is-a relationship. //2. For an empty class, the compiler typically inserts a char into its memory. When a class private inherits an empty class, the class has other data members, and the empty class char does not occupy the space of the derived class.
Effective C + + 6. Inheritance and object-oriented design