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
Explain what are accessor methods?
Can we inherit constructor in c++?
How we can differentiate between a pre and post increment operators during overloading?
When does the c++ compiler create temporary variables?
write a c++ program to create class student having datamember name,Roll_no,age,and branch intilcization all the member using constructor print the all the details on the screen.
What is a forward referencing and when should it be used?
Is overriding possible in c++?
What is the C-style character string?
What is c++ programming language?
Write a function to find the nth item from the end of a linked list in a single pass.
What is a pointer how and when is it used?
Write a program to show polymorphism in C++?
What is the difference between global variables and static varables?
Can we use clrscr in c++?
Why c++ is faster than java?