1. With multiple inheritance, it is possible for a derived class to inherit the same name from more than one base class, which results in ambiguity. Even if the same name from different base classes has different access levels, there is still a possibility of ambiguity, because the name lookup rule for C + + is to find the best match first. Then check for usability. You can use the scope operator to explicitly specify which class the name you are using belongs to.
2. If more than one base class inheriting from multiple inheritance inherits from the same class, it will result in "Diamond type inheritance", i.e. a->b; a->c; B,c->d, this is the choice of whether to set a virtual base class. If you do not use virtual inheritance, then a in D will have two entities (a copy from B, a copy from C), to make a in D only one copy, then b,c to a inheritance should use virtual inheritance, which will incur additional costs, including: 1. Classes that use virtual inheritance produce larger objects than those that do not use virtual inheritance. 2). Accessing virtual base class member variables is also slower than accessing a non-virtual base class. 3). The rule of "virtual base classes initialization" is more complex and less intuitive than non-virtual bases, because the initialization responsibility of the virtual base class is at the bottom of the inheritance hierarchy, which means that the underlying derived class must always recognize its virtual base class when initializing it. and must assume the responsibility of virtual base class initialization. This burden is especially noticeable when a new derived class is added.
3. Therefore, it is not necessary not to use multiple inheritance, even if multiple inheritance is necessary, and to avoid using virtual base classes, even if you must use virtual base classes, and try to avoid placing data members in virtual base classes to avoid the extra time cost of accessing data members and the burden of initializing virtual base classes.
4. Of course, multiple inheritance also has its "legitimate purpose": When a class public inherits from another class (Is-a relationship), and the former needs to be implemented with a third class (is-implementation-in-terms-of relationship), and with private inheritance, A 22 combination of public inheritance and private inheritance is required.
Effective C + + clause 40 explicit and prudent use of multiple inheritance