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 are the 5 oop principles?
Give an example where we have to specifically use C programming language and C++ programming language cannot be used?
How do you explain polymorphism?
#include
What is polymorphism give a real life example?
if i have same function with same number of argument but defined in different files. Now i am adding these two files in a third file and calling this function . which will get called and wht decide the precedence?
Is abstract thinking intelligence?
Get me a number puzzle game-program
What are the advantages of polymorphism?
What is methods in oop?
What is the diamond problem in inheritance?
c++ program to swap the objects of two different classes
What is static modifier?
What makes a language oop?
How do you define social class?