C++ Constructors Question:
Download Questions PDF

What is Virtual destructors?


The explicit destroying of object with the use of delete operator to a base class pointer to the object is performed by the destructor of the base-class is invoked on that object.

The above process can be simplified by declaring a virtual base class destructor.
All the derived class destructors are made virtual in spite of having the same name as the base class destructor. In case the object in the hierarchy is destroyed explicitly by using delete operator to the base class pointer to a derived object, the appropriate destructor will be invoked.

Download C++ Constructors Interview Questions And Answers PDF

Previous QuestionNext Question
What is virtual constructor?Which of the following statement is correct?

A. Destructor destroys only integer data members of the object.
B. Destructor destroys only float data members of the object.
C. Destructor destroys only pointer data members of the object.
D. Destructor destroys the complete object.