🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.int
  2. B.std::string
  3. C.std::runtime_error
  4. 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 →