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 Macro? What is the difference between a NULL Pointer and a NULL Macro?

1048


List the special characteristics of constructor.

1123


Can you explicitly call a destructor on a local variable?

976


What is the difference between an external iterator and an internal iterator?

1047


Why are pointers not used in c++?

1080


How would you implement a substr() function that extracts a sub string from a given string?

991


Const char *p , char const *p What is the difference between the above two?

1151


What is #include sstream?

1007


What are the uses of c++ in the real world?

978


What is the best way to take screenshots of a window with c++ in windows?

992


What is the difference between ++ count and count ++?

1081


What is a type library?

1058


What is std :: endl?

972


What are iterators in c++?

961


Is c++ a good beginners programming language?

1011