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
why is c++ called oops? Explain
What is the difference between containment and delegation?
Given the following seqment of code containing a group of nested if instructions: y = 9; if ((x==3) || (x == 5)) y++; else if (x == 2) y *= 2; else if (x == ) y-= 7; else y = 8; if the value of x is 4 before the nested IFs are executed, what is the value of y after the nested IFs are executed?
Why should we use null or zero in a program?
Is there structure in c++?
What is a list c++?
What is prototype for that c string function?
Is oops and c++ same?
What is rtti in c++?
Can create new c++ operators?
Explain how overloading takes place in c++?
How to defines the function in c++?
Why was c++ created?
What is the use of ::(scope resolution operator)?
Explain the static member function.