Order of Constructor Invocation is Base Class then Derived Class
While order of Destructor Invocation is Derived Class and then Base Class
However, this can be understood diagrammatically as below:
A Derived class is a specialization of a Base Class. This is means some features are added or modified in the specialized (Derived) class.
- To construct above diagram, I would first construct inner box (base class) and then construct outer box (derived class). That is why Base class constructor is invoked before the derived class constructor
- And when I have to erase (destruct) the diagram, I will first erase the outer box (derived class) and then erase the inner box (base class). That is why Derived class destructor is invoked before base class destructor