Answer Posted / kamil mohamed
virtual destructor is recommended when you want to destroy
(delete) an object through it's parent pointer. This good
habit enforces proper cleanup of derived classes
Example:
class Employee {
virtual ~Employee() {}
};
class Manager : public Employee {
~Manager() {}
}
Manager * m = new Employee();
delete m; // <--
| Is This Answer Correct ? | 6 Yes | 1 No |
Post New Answer View All Answers
Explain the advantages of inheritance.
How do you achieve polymorphism?
what type of question are asked in thoughtworks pair programming round ?
what are the ways in which a constructors can be called?
What are objects in oop?
what are the different types of qualifier in java?
What makes a language oop?
which feature are not hold visual basic of oop?
Why is destructor used?
What is oops?what is its use in software engineering?
Why we use classes in oop?
What is polymorphism give a real life example?
Write A Program to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)
Are polymorphisms mutations?
What is a class oop?