← Back to Question List
C++ Quiz #152
Nested try With a Rethrow
The inner handler prints a line and then rethrows with a bare throw;. What is printed?
📄 Code
1#include <iostream>2#include <stdexcept>34int 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}