when can we use virtual destructor?
Answer Posted / n
Virtual Destructor is a concept, comes into picture when one
will try to delete the base object pointer pointing to
derived class.
Base* pb = new Derived();
delete pb;
In this case if Base class destructor is not virtual then
only base class destructor will be called up for clean up.
While if we make Base class destructor as virtual then
1. Derived class destructor will be called
2. Base class destructor will be called up
Proper clean up of the objects from derived as well as base
class. Mission Accomplish
Is This Answer Correct ? | 36 Yes | 1 No |
Post New Answer View All Answers
Function can be overloaded based on the parameter which is a value or a reference. Explain if the statement is true.
What is flush programming?
Why do we use using namespace std in c++?
Explain terminate() function?
Why do we need c++?
What is static function? Explain with an example
How are Structure passing and returning implemented by the compiler?
Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create
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?
What is null pointer and void pointer and what is their use?
What is function prototyping?
What is heap sort in c++?
What is this weird colon-member (" : ") syntax in the constructor?
What is a far pointer? where we use it?