Explain the need for "Virtual Destructor"?
Answer Posted / lylez00
If A is a base class, and from that, B is derived, and a
dynamically allocated object of type B is deleted via a
pointer of type A, then B's destructor will not be invoked
unless A's destructor is virtual.
A *a = new B();
delete a; // won't invoke B's destructor unless A's
destructor is virtual
| Is This Answer Correct ? | 12 Yes | 3 No |
Post New Answer View All Answers
How do you invoke a base member function from a derived class in which you’ve overridden that function?
Why is c++ still best?
Why is it called c++?
What do you understand by zombie objects in c++?
What is purpose of abstract class?
Differentiate between the message and method in c++?
In which situation the program terminates before reaching the breakpoint set by the user at the beginning of the mainq method?
What is class in c++ with example?
Does c++ have string data type?
How we can differentiate between a pre and post increment operators during overloading?
What is a volatile variable in c++?
What is split a string in c++?
Is c++ fully object oriented?
Discuss the possibilities related to the termination of a program before entering the mainq method?
What is the difference between #import and #include?