Constructors and destructors are invoked the same way in multiple inheritance as in single inheritance. Listing 7 is an example.
Listing 7: | constructor |
When myC is created as an auto local variable, the constructors A::A() and B::B() are called first, then C::C() is called.
When myC is destroyed when the subroutine returns, the destructor C::~C() is called first, then A::~A() and B::~B() are called.
Note that the order of the calling of the superclasses’ constructors and destructors should not matter, as each super class only handles its own part without visibility of the other superclass.