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 makes a language oop?

0 Answers  


Can we create object of interface?

0 Answers  


i=20;k=0; for(j=1;k-i;k+=j<10?4:3) { cout<<k; } //please comment on the output

0 Answers  


What is virtual Function.

1 Answers   Wipro,


WILL I GET A guaranteed JOB AFTER DOING bsc()IT) and GNIIT from an NIIT CENTRE??

21 Answers   Biocon, MIT, NIIT,






What is the highest level of cohesion?

0 Answers  


How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization?

1 Answers   IntraLogic,


What are the OOPS concepts?

106 Answers   A1 Technology, Bajaj, CTS, EDS, HP, Infosys, Intel, Microsoft, MNC, Persistent, PlanetSoft, ProConstructor, TCS, Virtusa, Wipro, YSoft Solutions,


Why do we need polymorphism in c#?

0 Answers  


i^=j; j^=i; i^=j; value of i,j

1 Answers  


You attempt to query the data base with this command: SELECT name, salary FROM employee WHERE salary=(SELECT salary FROM employee WHERE last name='Wagner' OR dept no=233) Choose most appropriate option from the following: 1)Sub-queries are not allowed in the where clause. 2)a multiple row sub-query used with a single row comparison operator. 3)a single row query is used with a multiple row comparison operator.

10 Answers   Zycus Infotech,


Will I be able to get a picture in D drive to the c++ program? If so, help me out?

0 Answers  


Categories