Answer Posted / uma sankar pradhan
A virtual destructor is needed when we are deleting a
object of derived class using a base class pointer.
i.e.,
base *b=new derived;
delete(b);
Let's say,we have allocated memory dynamically in derived
class constructor to a pointer data member and we
deallocated it in the destructor to avoid memory leakage
When the object is deleted through base class pointer,
only the base class destructor is invoked.consequently,the
dynamically allocated space remains unreleased.so it leads
to memory leak
| Is This Answer Correct ? | 34 Yes | 1 No |
Post New Answer View All Answers
What is data binding in oops?
How do you achieve runtime polymorphism?
Is data hiding and abstraction same?
Which language is pure oop?
What is coupling in oop?
What is abstract class in oop?
What is polymorphism give a real life example?
Which is better struts or spring?
Get me an image implementation program.
Why is destructor used?
What is object in oop with example?
How to call a non virtual function in the derived class by using base class pointer
What is polymorphism explain its types?
Hi friends I have experience of 6 months in website design and maintanence. Now i am looking for other IT jobs.. to switch platform. please post any interview you know in chennai.
What are properties in oop?