24 Nov 2019

  • November 24, 2019
  • Amitraj
We have presented you the sequence in which constructors and destructors get called in single and multiple inheritance.

*Constructor and destructor in single inheritance:

->Base class constructors are called first and the derived class constructors are called next in single inheritance.

-> Destructor is called in reverse sequence of constructor invocation i.e. The destructor of the derived class is called first and the destructor of the base is called next.


*Constructor and destructor in multiple inheritance:

-> Constructors from all base class are invoked first and the derived class constructor is called.

Order of constructor invocation depends on the order of how the base is inherited.

-> However, the destructor of derived class is called first and then destructor of the base class

Translate

Popular Posts