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

How do you invoke a base member function from a derived class in which you’ve overridden that function?

1172


Why is c++ still best?

1024


Why is it called c++?

1086


What do you understand by zombie objects in c++?

1164


What is purpose of abstract class?

1127


Differentiate between the message and method in c++?

1117


In which situation the program terminates before reaching the breakpoint set by the user at the beginning of the mainq method?

1138


What is class in c++ with example?

1371


Does c++ have string data type?

1163


How we can differentiate between a pre and post increment operators during overloading?

1156


What is a volatile variable in c++?

1570


What is split a string in c++?

1250


Is c++ fully object oriented?

1020


Discuss the possibilities related to the termination of a program before entering the mainq method?

1002


What is the difference between #import and #include?

1104