IT Placement Papers Programming C++
This category contains C++ Interview Questions and Answers |
Virtual Destructor - What is the need for a 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 classes 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.
Only registered users can write comments. Please login or register.
|