// Identity and access of the derived class members // overwrite the Same Name // when the derived class and the base class have the same members: // 1. if the name is not forcibly specified, the derived class object uses the same name Member in the derived class. // 2. If you want to access a member of the same name that is overwritten in the base class through a derived class object, use the base class name. // Ambiguity: // 1. when a member of the same name appears between the base class and the derived class, or between the base class, the ambiguity (uncertainty) of the access will occur-using virtual functions (Chapter 1) or the rule (same name overwrite. // 2. when a derived class is derived from multiple base classes and these base classes are derived from the same base class, this will generate ambiguity-the virtual base class will be used to solve the problem. // Introduction of the virtual base class // The introduction of the virtual base class, used for occasions with a common base class // declaration // use virtual to describe the base class, for example: // class B1: virtual public B // role // It is mainly used to solve the problem that the same base class may be inherited multiple times during multi-inheritance. // provide a unique base class member for the farthest derived class without repeatedly generating multiple copies. // note: // when inheriting the first level, the common base class must be designed as a virtual base class. # Include <iostream. h> class B0 // acoustic basic class B0 {public: // external interface int NV; void fun () {cout <"Member of B0" <Endl ;}}; class B1: virtual public B0 // B0 is a virtual base class. The derived B1 class {public: // new external interface int nv1 ;}; Class B2: virtual public B0 // B0 is a virtual base class derived from B2 class {public: // new external interface int nv2;}; Class D1: Public B1, public B2 // D1 Declaration of the derived class {public: // new external interface int nvd; void Fund () {cout <"Member of D1" <Endl ;}}; int main (void) {D1 D1; // declare D1 Class Object d1d1. NV = 2; // use the direct base class d1.fun (); Return 0 ;}