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...

when can we use virtual destructor?

Answer Posted / sagarson

Need for a virtual destructor
1.destructor for the base parts are invoked automatically
2.we might delete a ptr to the base type that actually
points to a derived object
3.if we delete a ptr to base then the base class destructor
is run and the members of the base class are cleared up. If
the object is a derived type then the behavior is undefined
4.to ensure that the proper destructor is run the destructor
must be virtual in the base class
5.virtual destructor needed if base pointer that points to a
derived object is ever deleted (even if it doesnt do any work)

Is This Answer Correct ?    34 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Are c and c++ similar?

1113


What is a static member?

1092


Can a built-in function be recursive?

1078


What is the identity function in c++? How is it useful?

1097


How does atoi function work?

1178


Explain the isa and hasa class relationships.

1103


Write about the use of the virtual destructor?

1060


Do you know what are static and dynamic type checking?

1104


Why do we learn c++?

1028


What is c++ code?

1176


What jobs can you get with a c++ certification?

1105


What is the difference between delegation and implemented-in-terms-of?

1055


Is std :: string immutable?

1104


What do you mean by public protected and private in c++?

1114


Can we use this pointer in a class specific, operator-overloading function for new operator?

1149