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

what is virtual destructor

Answer Posted / rock

When a derived class object pointed to by a base class
pointer dynamically is deleted only the base class
destructor is invoked inorder to even invoke derived class
destructor we use virtual destructor.

class shape
{
virtual ~shape(){}
};
class circle:public shape
{
~circle(){}
};
void main()
{
shape *sh = new circle;
delete sh; //both the destructors are invoked
}

If virtual keyword is not added to the base class
destructor only the base class destructor is called.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you define a class in oop?

1126


What is inheritance in oop?

1036


What is constructor in oop?

1117


What is data binding in oops?

1099


What are the 4 main oop principles?

1225


What is use of overloading?

1147


What is the problem with multiple inheritance?

1167


Can destructor be overloaded?

1035


What is the purpose of polymorphism?

1126


What does I oop mean?

1076


Which language is pure oop?

1010


What is the difference between a mixin and inheritance?

992


Which is better struts or spring?

1055


What is encapsulation in oop?

1052


What is a null tree?

1138