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 extern c++?
What is the C-style character string?
What is unary operator? List out the different operators involved in the unary operator.
Explain the static storage classes in c++.
What is a constructor in c++ with example?
What are the advantages of using a pointer?
Why is c++ still popular?
How does a copy constructor differs from an overloaded assignment operator?
Is it possible to pass an object of the same class in place of object reference to the copy constructor?
How are the features of c++ different from c?
What is the best c++ ide?
When is the copy constructor called?
Which of the following is evaluated first: a) && b) || c) !
What are the two main components of c++?
What do you mean by early binding?