What is the order of destructor execution in C++?
base and then derived
derived and then base
Generally it will execute derived class destructor, and then base class destructor. Exception for this rule: In case if you are taking a derived class object into a base class pointer or base class reference variable, and if you forget to give virtual keyword for base class destructor, then in that case it will execute only base class destructor.
Back To Top