CJCoding With Joseph
15free / daySign inCreate account
← Back to Question List

Select topics to narrow your question pool, then enable Random to jump to a random question matching your filters.

Topics:
C++ Quiz #152

Nested try With a Rethrow

mediumExceptions

The inner handler prints a line and then rethrows with a bare throw;. What is printed?

📄 Code

1#include <iostream>
2#include <stdexcept>
3 
4int main() {
5 std::cout << "start\n";
6 try {
7 try {
8 throw std::runtime_error("boom");
9 } catch (const std::exception& e) {
10 std::cout << "inner saw " << e.what() << "\n";
11 throw;
12 }
13 std::cout << "after inner try\n";
14 } catch (const std::exception& e) {
15 std::cout << "outer saw " << e.what() << "\n";
16 }
17 std::cout << "end\n";
18 return 0;
19}