How the compilers implement the virtual inheritance?
In the following code:
class A {
public:
A(int) {}
};
class B : public virtual A {
publ
The Itanium C++ ABI is a useful resource for all questions like "how could this be implemented by C++ compilers".
In particular 5.1.4 Other Special Functions and Entities list different special member functions for different purposes:
::= C1 # complete object constructor ::= C2 # base object constructor ::= C3 # complete object allocating constructor ::= D0 # deleting destructor ::= D1 # complete object destructor ::= D2 # base object destructor
The 1.1 Definitions section is useful (but not complete):
base object destructor of a class T
A function that runs the destructors for non-static data members of T and non-virtual direct base classes of T.
complete object destructor of a class T
A function that, in addition to the actions required of a base object destructor, runs the destructors for the virtual base classes of T.
deleting destructor of a class T
A function that, in addition to the actions required of a complete object destructor, calls the appropriate deallocation function (i.e,. operator delete) for T.
From these definitions, the purpose of the complete object constructor and of the base object constructor are obvious.