Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Why and when is a virtual destructor needed?

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


Please Help Members By Posting Answers For Below Questions

What is data binding in oops?

1099


How do you achieve runtime polymorphism?

1049


Is data hiding and abstraction same?

1044


Which language is pure oop?

1012


What is coupling in oop?

1035


What is abstract class in oop?

1014


What is polymorphism give a real life example?

1038


Which is better struts or spring?

1058


Get me an image implementation program.

1988


Why is destructor used?

1024


What is object in oop with example?

1246


How to call a non virtual function in the derived class by using base class pointer

6565


What is polymorphism explain its types?

1167


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.

2198


What are properties in oop?

1089