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

What are the implicit member functions of class?

1026


Where do I find the current c or c++ standard documents?

1026


How will you call C functions from C ++ and vice-versa?

1078


When do you call copy constructors?

1082


Write a program to interchange 2 variables without using the third one.

1004


How can we check whether the contents of two structure variables are same or not?

1019


Explain class invariant.

992


What is a set in c++?

918


What do you mean by enumerated data type?

1001


What are the types of container classes?

1085


How do we implement inheritance in c++?

1072


What is the full form of ios?

986


Explain how to initialize a const data member.

1071


What do you mean by function and operator overloading in c++?

990


What are stacks?

1009