← Quiz: Exception Handling in C++: all 10 questions
Quiz: Exception Handling in C++ · Question 8 of 10
Inside a catch block, what is the difference between throw; and throw e; (where e is const exception &)?
Inside a catch block, what is the difference between throw; and throw e; (where e is const exception &)?
- A.There is no difference
- B.throw; rethrows the original object with its real type; throw e; throws a new copy of type exception
- C.throw e; is faster
- D.throw; ends the program
Answer & explanation
Correct answer: throw; rethrows the original object with its real type; throw e; throws a new copy of type exception
Copying through the base-class reference slices the object, so callers catching the derived type miss it.
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 →