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
Prepare me a program for the animation of train
Why is polymorphism used?
How do you achieve runtime polymorphism?
What is the purpose of enum?
officer say me - i am offered to a smoking , then what can you say
What is difference between abstraction and encapsulation?
#include
Why do we use class in oops?
write a C++ program for booking using constructor and destructor.
What is difference between inheritance and polymorphism?
What is abstraction in oop with example?
What is debug class?what is trace class? What differences are between them? With examples.
How do you explain polymorphism?
Give an example where we have to specifically use C programming language and C++ programming language cannot be used?
write knight tour problem which is present in datastructure