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 a stack? How it can be implemented?
What is the purpose of template?
How can virtual functions in c++ be implemented?
Will the following program execute?
What is #include iomanip?
What is the best book for c++ beginners?
What is the use of turbo c++?
Are c and c++ different?
Define Virtual function in C++.
Which header file allows file i/o with streams a) fileio.h b) iostream.h c) fstream.h
What is class syntax c++?
Define macro.
Explain the use of virtual destructor?
Should a constructor be public or private?
What is a block in c++?