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
write a program that withdrawals,deposits,balance check,shows mini statement. (using functions,pointers and arrays)
What is #include cmath?
Differentiate between structure and class in c++.
Tell me what are static member functions?
What is the exit function in c++?
Explain the term memory alignment?
Can a constructor be private?
What is function overloading c++?
What is const pointer and const reference?
What is setf in c++?
What is data type in c++?
What are its advantages and disadvantages of multiple inheritances (virtual inheritance)?
What are friend functions in C++?
Define namespace in c++?
What is the full form of c++?