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

Write about the various sections of the executable image?

1031


What is purpose of abstract class?

1127


To what does “event-driven” refer?

1112


What is c++ mutable?

1166


List the advantages of inheritance.

1184


What is meant by entry controlled loop? What all C++ loops are exit controlled?

1148


What are dynamic type checking?

1097


What is a stack c++?

1053


Is it legal in c++ to overload operator++ so that it decrements a value in your class?

1114


What are the implicit member functions of class?

1135


What is endl c++?

1154


What are c++ tokens?

1120


What do you mean by function overriding & function overloading in c++?

1274


What is a manipulative person?

1076


Explain linked list using c++ with an example?

1140