← Quiz: Exception Handling in C++: all 10 questions
Quiz: Exception Handling in C++ · Question 10 of 10
Why should a destructor never throw an exception?
Why should a destructor never throw an exception?
- A.Destructors cannot contain code
- B.Exceptions are not allowed in classes
- C.Destructors run during stack unwinding; a second exception at that moment terminates the program
- D.It would make the object live forever
Answer & explanation
Correct answer: Destructors run during stack unwinding; a second exception at that moment terminates the program
Destructors are noexcept by default, so a throw from one ends the program.
Can you get the rest right without peeking?
Take the timed Quiz: Exception Handling in C++ quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →