← Back to Question List
C++ Quiz #46
Catch Block Ordering
This code has a problem related to the order of catch blocks. What is the issue?
📄 Code
1#include <iostream>2#include <stdexcept>3using namespace std;45int main() {6 try {7 throw runtime_error("problem");8 } catch (const exception& e) {9 cout << "Base: " << e.what() << endl;10 } catch (const runtime_error& e) {11 cout << "Derived: " << e.what() << endl;12 }13 return 0;14}