Practice mode C++

Inside a catch block, what does the statement throw; (with no operand) do?

Correct answer C. It rethrows the exception currently being handled

Explanation

A bare throw; rethrows the current exception object itself, preserving its original dynamic type, so outer handlers can process it further. Writing throw e; instead would throw a copy of e, sliced to e's static type if caught as a base. Using throw; outside any active handler calls std::terminate.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.