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 / abc

When We Declare a Virtual Function In Base Class.
The Base Class Pointer Can Point To Derived Class objects.
And If we Try To Delete The Base Class Pointer ,it will Call
the base Class Destructor(Which Is Wrong).

To Handle Such Scenario,The Base Class Destructor need To
Be Declared As Virtual(Which Makes All The Derived Class
Destructors Virtual).Now The Base Class Pointer Will Call
The Respective Destructors(Ofcourse,It Is Decided at Run
Time.With The Virtual Mechanism.)

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a null object in c++?

1223


What is operators in c++?

1003


Explain the difference between abstract class and interface in c++?

980


Why c++ is called oop?

1105


If horse and bird inherit virtual public from animal, do their constructors initialize the animal constructor? If pegasus inherits from both horse and bird, how does it initialize animal’s constructor?

1205


How does the copy constructor differ from the assignment operator (=)?

1141


Why is c++ still used?

1083


What do you mean by static variables?

1170


What are separators in c++?

1085


Can a class be static in c++?

1090


What are friend functions in C++?

1064


What is an operator function? Describe the function of an operator function?

1144


What is input operator in c++?

1033


What is the equivalent of Pascal's Real a) unsigned int b) float c) char

1014


When should we use multiple inheritance?

1041