1, the total light on the paper, the bow of the debug is profound.
For the "Deep Exploration of C + + object Model" This type of book, the knowledge needed to be consolidated in time to achieve permanent memory.
2. There is a great relationship between the content layout and the reusability of virtual table after the realization of the merging branch of fictitious inheritance.
The order of inheritance determines the layout order of A and B, and then common the layout of the high address, the public virtual base class, at the tail of D.
Scenario 1:
Class A:public virtual common{...};
Class B:public virtual common{...; virtual void Notincommon () {}};
Class D:public A,public b{...}
The memory layout is:
D{a,b,common}; A and Common share a single virtual table
Scenario 1:
Class A:public virtual common{...};
Class B:public virtual common{...; virtual void Notincommon () {}};
Class D:public B,public a{...}
The memory layout is:
D{b,a,common}; High address from low address (view from top to bottom).
The inheritance list is somewhat equivalent to a variable declaration, which declares that the location holds a base class. D, a, common common a virtual table. Priority adjustment to be able to satisfy the status of single inheritance (to be continued.) ), and B is offset by. If the virtual table pointer of the current class is not visible in VS-this is unscientific, how could it not be found, in fact the virtual table pointer is the same as the last parent class object using the common one virtual table pointer variable. However, because the view is a base class object, it is said that there is no more virtual function for this derived object. Cond.
Virtual inherited memory layout Codex-based VS2012