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

Inline parameters : What does the compiler do with the parameters of inline function, that can be evaluated in runtime ?

2449


Which function cannot be overloaded c++?

1049


What is data hiding c++?

997


What is code reusability in c++?

1180


What is the difference between structures and unions?

1011


What are containers in c++?

937


How are pointers type-cast?

1060


What is private, public and protected inheritance?

1032


Describe delete operator?

1039


Can a Structure contain a Pointer to itself?

1069


What are guid? Why does com need guids?

1009


How do you find out if a linked-list has an end? (I.e. The list is not a cycle)

1103


Which bit wise operator is suitable for checking whether a particular bit is on or off?

970


What is exception handling? Does c++ support exception handling?

972


What are the advantages of inheritance in c++?

1043