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
If there are two catch statements, one for base and one for derived, which should come first?
Show the declaration for a static member variable.
What are features of c++?
write a function signature with various number of parameters.
Explain selection sorting?
How do you define/declare constants in c++?
What is the difference between while and do while loop? Explain with examples.
How can you tell what shell you are running on unix system?
Is it possible to provide special behavior for one instance of a template but not for other instances?
Why is c++ so fast?
Write a short code using c++ to print out all odd number from 1 to 100 using a for loop
Should the member functions which are made public in the base class be hidden?
what is data abstraction in C++?
Write a program using merge () function to combine the elements of array x[ ] and y[ ] into array z[ ].
What is name hiding in c++?