Answer Posted / nk
There is nothing like virtual constructors but we can have
virtual destructors so that the destructor of the correct
object is called.
Ex.
Base *bptr = new derived()
delete bptr; then the destructor of the derived objetc is
called when the base destructor is marked as virtual.
else destructore of base class is called and may lead to
memory leak if we have allocated any new memory.
| Is This Answer Correct ? | 18 Yes | 1 No |
Post New Answer View All Answers
What is polymorphism explain?
Is html an oop?
Why is static class not inherited?
What is new keyword in oops?
Why multiple inheritance is not possible?
Why is oop useful?
What is the highest level of cohesion?
Is react oop?
How Do you Code Composition and Aggregation in C++ ?
What is coupling in oops?
What are the components of marker interface?
Why do pointers exist?
What are the three main types of variables?
What are the benefits of oop?
Why is encapsulation used?