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 does it mean when someone says I oop?
What type of loop is a for loop?
class CTest { public: void someMethod() { int nCount = 0; cout << "This is some method --> " << nCount; } }; int main() { CTest *pctest; pctest->someMethod(); return 0; } It will executes the someMethod() and displays the value too. how is it possible with our creating memory for the class . i think iam not creating object for the class. Thanks in Advance... Prakash
Which is better struts or spring?
What are different oops concepts?
Which method cannot be overridden?
What is the difference between a mixin and inheritance?
What is polymorphism programming?
What is property in oops?
Are polymorphisms mutations?
i got a backdoor offer in process global,Bangalore..Can i work with it?
design a c++ class for the chess board,provide a c++ class definition for such class(only class definition is required)
What is multilevel inheritance explain with example?
What is a null tree?
What language is oop?