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

Explain the need for "Virtual Destructor"?

Answer Posted / lylez00

If A is a base class, and from that, B is derived, and a
dynamically allocated object of type B is deleted via a
pointer of type A, then B's destructor will not be invoked
unless A's destructor is virtual.

A *a = new B();
delete a; // won't invoke B's destructor unless A's
destructor is virtual

Is This Answer Correct ?    12 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Refer to a name of class or function that is defined within a namespace?

1065


Which operations are permitted on pointers?

960


Which ide is best for c++?

1010


When should we use multiple inheritance?

1011


Is c# written in c++?

939


Explain what are single and multiple inheritances in c++?

989


What are the advantages of inheritance in c++?

1063


What would happen on forgetting [], while deallocating an array through new?

1045


How a pointer differs from a reference?

1288


What are c++ templates used for?

1099


How can a called function determine the number of arguments that have been passed to it?

1099


Are vectors passed by reference c++?

951


What is stream and its types in c++?

1011


explain the reference variable in c++?

1029


What is vector string in c++?

1055