← Quiz: Exception Handling in C++: all 10 questions
Quiz: Exception Handling in C++ · Question 7 of 10
What is the best base class for your own InsufficientFunds exception?
What is the best base class for your own InsufficientFunds exception?
- A.int
- B.std::string
- C.std::runtime_error
- D.std::vector
Answer & explanation
Correct answer: std::runtime_error
Deriving from runtime_error gives a what() message and lets catch (const exception &) handle it too.
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 →