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

when can we use virtual destructor?

Answer Posted / n

Virtual Destructor is a concept, comes into picture when one
will try to delete the base object pointer pointing to
derived class.
Base* pb = new Derived();
delete pb;
In this case if Base class destructor is not virtual then
only base class destructor will be called up for clean up.

While if we make Base class destructor as virtual then
1. Derived class destructor will be called
2. Base class destructor will be called up

Proper clean up of the objects from derived as well as base
class. Mission Accomplish

Is This Answer Correct ?    36 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

write a program that withdrawals,deposits,balance check,shows mini statement. (using functions,pointers and arrays)

2293


What is #include cmath?

1040


Differentiate between structure and class in c++.

1020


Tell me what are static member functions?

1035


What is the exit function in c++?

936


Explain the term memory alignment?

1159


Can a constructor be private?

1024


What is function overloading c++?

1020


What is const pointer and const reference?

1082


What is setf in c++?

1045


What is data type in c++?

968


What are its advantages and disadvantages of multiple inheritances (virtual inheritance)?

1143


What are friend functions in C++?

1009


Define namespace in c++?

998


What is the full form of c++?

1246