Interview Questions

Virtual Destructor - What is the need for “Virtual Destructor”?

C++ Interview Questions and Answers


(Continued from previous question...)

Virtual Destructor - What is the need for “Virtual Destructor”?

Destructors are declared as virtual because if do not declare it as virtual the base class destructor will be called before the derived class destructor and that will lead to memory leak because derived class’s objects will not get freed.Destructors are declared virtual so as to bind objects to the methods at runtime so that appropriate destructor is called.

(Continued on next question...)

Other Interview Questions