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 is data binding in oops?
What is abstraction in oops?
what type of questions
What is coupling in oop?
what's the basic's in dot net
How do you define a class in oop?
How is polymorphism achieved?
Why do we use inheritance?
Can we have inheritance without polymorphism?
Why do while loop is used?
Why do we use polymorphism in oops?
What is class encapsulation?
Write A Program to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)
What is protected in oop?
What is the difference between a mixin and inheritance?