What is virtual destructor? Why?
Answer Posted / 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 |
Post New Answer View All Answers
What exactly is polymorphism?
Is data hiding and abstraction same?
Why do we use encapsulation in oops?
Why is abstraction used?
What is an interface in oop?
What is Difeerence between List obj=new ArrayList(); and ArrayList obj=new ArrayList()?
Why is there no multiple inheritance?
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...
#include
How do you explain polymorphism?
What is object and class in oops?
What is property in oops?
What is abstraction in oop with example?
What does enum stand for?
What is encapsulation oop?