Back to Multiple Choice Quiz
Catch Block Ordering
C++ quiz · Question 46This 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}