← Back to Question List
C++ Quiz #48
Bare throw Rethrows
What is the output of this code?
📄 Code
1#include <iostream>2#include <stdexcept>3using namespace std;45void inner() {6 throw runtime_error("inner error");7}89void outer() {10 try {11 inner();12 } catch (const runtime_error& e) {13 cout << "Logging: " << e.what() << endl;14 throw; // rethrow15 }16}1718int main() {19 try {20 outer();21 } catch (const runtime_error& e) {22 cout << "Caught: " << e.what() << endl;23 }24 return 0;25}