Multiple choice technology programming languages

Is it possible to have a virtual destructor?

  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Virtual destructors are essential in C++ polymorphism. When you delete a derived class object through a base class pointer, a virtual destructor ensures the correct destructor chain is called (derived first, then base). Without virtual destructors, only the base class destructor executes, causing resource leaks and undefined behavior.