Which of the following exists in C++ ?
-
virtual constructor
-
virtual destructor
-
both A and B
-
None of the above
B
Correct answer
Explanation
C++ supports virtual destructors but not virtual constructors. Virtual destructors ensure proper cleanup when deleting derived objects through base pointers, while constructors cannot be virtual since they initialize the vtable itself.