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

Why polymorphism is used in oops?

0 Answers  


what is the difference between a package and a software?

3 Answers  


I have One image (means a group photo ) how to split the faces only from the image?............ please send the answer nagadurgaraju@gmail.com thanks in advace...

0 Answers  


what is function over loading?

5 Answers  


What does I oop mean?

0 Answers  






class CTest { public: void someMethod() { int nCount = 0; cout << "This is some method --> " << nCount; } }; int main() { CTest *pctest; pctest->someMethod(); return 0; } It will executes the someMethod() and displays the value too. how is it possible with our creating memory for the class . i think iam not creating object for the class. Thanks in Advance... Prakash

0 Answers  


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create.

1 Answers  


#include <iostream> using namespace std; int main() { int a = 2; int c[5][5]; for (int x=0;x<5;x++) { for (int y=0;y<5;y++) { c[x][y] = x*y; } } cout << c[a][c[1][4]]; }

2 Answers   TCS, Wipro,


What is abstract class in oops?

0 Answers  


What are the advantages of polymorphism?

0 Answers  


When not to use object oriented programming?

0 Answers  


Is abstract thinking intelligence?

0 Answers  


Categories