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
What is the real time example of inheritance?
What is pointer in oop?
Why it is called runtime polymorphism?
What are the features of oop?
What is inheritance write a program to show use of inheritance?
Why interface is used?
What is the difference between encapsulation and polymorphism?
What is overriding in oop?
Can you explain polymorphism?
Can enum be null?
What is the difference between procedural programming and oops?
What is ambiguity in inheritance?
what is difference between class template and template class?
What is meant by multiple inheritance?
What exactly is polymorphism?