What is virtual destructor? Why?

Answers were Sorted based on User's Feedback



What is virtual destructor? Why?..

Answer / sagarika patra

When a destructor is declared as virtual in the base class
is known as virtul destructor.

Whenever any object of derived class of base type is freed
(using delete operator),the destructor of the derived class
is called and the memory allocated by derived class
variables are freed ,leaving the memory allocated by the
base class variables as unfreed.

Hence by declaring the base class destructor as
virtual,both the destructor will called in order.

Is This Answer Correct ?    9 Yes 0 No

What is virtual destructor? Why?..

Answer / mugdha taru

virtual destructor are those who can not override while
redefining derived class.

Is This Answer Correct ?    2 Yes 3 No

What is virtual destructor? Why?..

Answer / riya piyush jain

In object-oriented programming, a destructor (sometimes
shortened to dtor) is a method which is automatically
invoked when the object is destroyed. Its main purpose is
to clean up and to free the resources which were acquired
by the object along its life cycle and unlink it from other
objects or resources invalidating any references in the
process. The use of destructors is key to the concept of
Resource Acquisition Is Initialization.

Is This Answer Correct ?    4 Yes 8 No

Post New Answer

More OOPS Interview Questions

what about you? wahat is your object? introduce your self?

1 Answers   Ajmal Perfumes, TCS,


why the memory allocated with new cant be freed using free()

2 Answers  


What is an example of genetic polymorphism?

0 Answers  


What is the output of the following code: int v() { int m=0; return m++; } int main() { cout<<v(); } 1) 1 2) 0 3) Code cannot compile

4 Answers  


What is the different between Applet and Application?

2 Answers  






Can static class have constructor?

0 Answers  


What is ambiguity in c++

4 Answers   Accenture, Mphasis,


When is an object created and what is its lifetime?

4 Answers   IBM,


Conversion from a basic type to a class type may be achieved using______________

5 Answers   HCL,


What is the renewal class?

0 Answers   Ebix, IBM,


how much classes are used in c++

5 Answers  


What is the concept of object oriented program?

6 Answers  


Categories