What is the virtual destructor. When and why do you need it? (Be surprised if you are not asked this question!)

Destructor implemented by declaring a base class's destructor with the keyword virtual. A virtual destructor ensures that, when delete is applied to a base class pointer or reference, it calls the destructor implemented in the derived class, if an implementation exists.

No comments: