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
What is inheritance in 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
Write A Program to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)
What is the example of polymorphism?
What is debug class?what is trace class? What differences are between them? With examples.
What are the advantages of polymorphism?
How long to learn object oriented programming?
What is multilevel inheritance explain with example?
What is this pointer in oop?
What are the two different types of polymorphism?
What is meant by oops concept?
what is the sylabus for priliminaries?
Whats oop mean?
What are properties in oop?
What does and I oop and sksksk mean?