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
What is capacity in vector in c++?
How is c++ different from java?
Explain register storage specifier.
What is encapsulation in c++ with example?
What are the advantages of using a pointer?
Is c++ proprietary?
What is #include cstdlib in c++?
What are built-in functions? What is the syntax for the definition?
What does it mean to declare a member function as virtual?
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 link a c program with a c function?
When do we use copy constructors?
Which coding certification is best?
How do you invoke a base member function from a derived class in which you’ve overridden that function?
Explain what happens when a pointer is deleted twice?