🎙 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 3 of 10

Why should you catch exceptions by const reference?

Why should you catch exceptions by const reference?

  1. A.References are required by the compiler
  2. B.It avoids copying and keeps the real derived type, so what() and extra fields work
  3. C.It makes the exception non-fatal
  4. D.It lets you modify the thrown object
Answer & explanation

Correct answer: It avoids copying and keeps the real derived type, so what() and extra fields work

Catching by value copies the object and can slice a derived exception down to the base class.

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 →