← Quiz: Inheritance and Virtual Functions: all 10 questions
Quiz: Inheritance and Virtual Functions · Question 4 of 10
Why should a polymorphic base class have a virtual destructor?
Why should a polymorphic base class have a virtual destructor?
- A.To make it faster
- B.So deleting through a base pointer also runs the derived destructor
- C.Destructors can't be virtual
- D.To allow copying
Answer & explanation
Correct answer: So deleting through a base pointer also runs the derived destructor
Otherwise the derived part isn't cleaned up properly.
Can you get the rest right without peeking?
Take the timed Quiz: Inheritance and Virtual Functions quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →