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
What is size of string in c++?
Write about the use of the virtual destructor?
In c++, what is the difference between method overloading and method overriding?
What are the steps in the development cycle?
What is iomanip c++?
What are literals in C++?
write asingle linked list which read from two list & the do the following 1 sort the prime & nonprime num (prime should be less tn nonprime) 2 each node has a prime num followd by nonprime 3 add a new node into its sutable plce 4 erase the most three duplicated non prime num 5 find the least duplicated prime num
What do you mean by inheritance in c++? Explain its types.
Can circle be called an ellipse?
What is the difference between #define debug 0 and #undef debug?
What are separators in c++?
Which operations are permitted on pointers?
What is encapsulation in C++? Give an example.
Why do we use templates?
What do you mean by volatile and mutable keywords used in c++?