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

If there are two catch statements, one for base and one for derived, which should come first?

1078


Show the declaration for a static member variable.

1045


What are features of c++?

1262


write a function signature with various number of parameters.

1096


Explain selection sorting?

1125


How do you define/declare constants in c++?

1104


What is the difference between while and do while loop? Explain with examples.

1159


How can you tell what shell you are running on unix system?

1158


Is it possible to provide special behavior for one instance of a template but not for other instances?

1172


Why is c++ so fast?

1084


Write a short code using c++ to print out all odd number from 1 to 100 using a for loop

1078


Should the member functions which are made public in the base class be hidden?

1076


what is data abstraction in C++?

1121


Write a program using merge () function to combine the elements of array x[ ] and y[ ] into array z[ ].

1108


What is name hiding in c++?

1219