Multiple ChoiceBeginner 45s
Virtual destructor necessity
You plan to `delete` a derived object through a `Base*`. Base's destructor is non-virtual. What is the consequence?
Options
- 1The compiler inserts a runtime check that calls the derived destructor whenever deletion goes through Base*.
- 2Only the derived destructor runs; the base destructor is skipped, leaving the base sub-object uninitialized.
- 3It fails to compile, because deleting through a base pointer requires the base destructor to be virtual.
- 4Undefined behavior: only Base's destructor runs, so Derived's resources may leak or be corrupted.
Think you can answer under pressure?
Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.