1. Concept of Multi-inheritance: A class has two or more base classes.
Form: class <类名> : <访问属性> Class <类名> , <访问属性> Class <类名>
For example, class A: public class B, public class C
In the above definition, if both B and C have the print function, then the Class A object will call the print function, which is A defect in Multi-inheritance, to avoid this ambiguity, you can use the domain access character:, for example, Class A's object a accesses the print function in Class B. You can use. b: print ().
2. Under Multi-inheritance, a base class can appear multiple times in the hierarchy, for example, the following inheritance Structure
<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + QcDgxcnJ + signature + RMDgtcS21M/Signature/bP1rb + signature/Signature + signature/nA4KOs1eLR + signature/Signature + signature/J0tTN6sirz/uz/ bb + 0uXQ1MLwo7 + release/uz/release/dbWx + m/9da-vcd4kpha + release/release + release/T2rmyz + release/bP1rb + release + IDwvcD4KPHA + z8LD5srHy7XD97XEtPrC66O6PC9wPgo8cHJlIGNsYXNzPQ = "brush: java; "> # include Using namespace std; class Base {public: Base (int t): x (t) {} void print () {cout <
3. Construct sequence and destructor sequence in virtual inheritance
In the inheritance hierarchy of the above four classes of ABCD, the calling sequence of the constructor is A-B-C-D, and the calling sequence of the Destructor is just the opposite.
In a more complex inheritance structure, the virtual base class and common base class appear at the same time. The call priority of the virtual base class is higher than that of the non-virtual base class, no matter what inheritance level the virtual base class is located in, the constructor of the virtual base class is called before the non-virtual base class.