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

How do you know that your class needs a virtual destructor?

Answer Posted / som shekhar

If we are deriving from the base class and the base class
consist of some virtual function , then in this case the
base destructor should be virtual.
if you do some thing like this :

base* b = new derived;
delete b;

In this case if base destructor is NOT VIRTUAL then only
base destructor is called and derived destructor wont be
called resulting into memory leak.

But if the base destructor is virtual then derived class
destructor and base destructor both will be called.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

an operation between an integer and real always yeilds a) integer result b) real result c) float result

1159


What is c++ redistributable?

1236


What is the difference between structures and unions?

1064


Difference between a copy constructor and an assignment operator.

1004


How many different levels of pointers are there?

1215


What is the latest c++ standard?

1152


Do you know about latest advancements in C++ ?

1251


What is c++ used for in games?

1171


Is recursion allowed in inline functions?

1087


Difference between overloaded functions and overridden functions

1060


What is conditions when using boolean operators?

1238


What is the difference between c++ and turbo c++?

1203


How much maximum can you allocate in a single call to malloc()?

1107


How do you declare A pointer to a function which receives nothing and returns nothing

1239


Explain the difference between using macro and inline functions?

1127