Answer Posted / pankajkolte
Virtual Destructor is used basically to ensure proper the
sequence of call to destructor.
class Employee {
virtual ~Employee() {}
};
class Manager : public Employee {
~Manager() {}
}
Employee * m = new Manager();//here was the mistake
delete m; // <-
In this case base class destructor if marked as virtual so
as derived class destructor will get called first then base
class destructor.
Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Write a c++ program to display pass and fail for three student using static member function
What is interface in oop?
Why is static class not inherited?
What is the real time example of encapsulation?
Why oops is important?
Why is oop useful?
Can an interface inherit a class?
What is use of overloading?
What is the use of oops?
What is overloading in oops?
What are the 3 pillars of oop?
Why do we need oop?
How to hide the base class functionality in Inheritance?
Which is not an object oriented programming language?
Why multiple inheritance is not allowed?