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 abstraction oop?
class CTest { public: void someMethod() { int nCount = 0; cout << "This is some method --> " << nCount; } }; int main() { CTest *pctest; pctest->someMethod(); return 0; } It will executes the someMethod() and displays the value too. how is it possible with our creating memory for the class . i think iam not creating object for the class. Thanks in Advance... Prakash
What is property in oops?
officer say me - i am offered to a smoking , then what can you say
What are the 3 principles of oop?
What is class and example?
Templates mean
What is new keyword in oops?
What are main features of oop?
What do you mean by variable?
What is the point of polymorphism?
What is the difference between a constructor and a destructor?
c++ program to swap the objects of two different classes
What are the advantages of polymorphism?
Is html an oop?