#include #include using namespace std; void f() { throw invalid_argument("1"); } void g() { throw runtime_error("2"); } int main() { try { f(); } try { g(); } catch(const runtime_error& e) { cout << "3 " << e.what() << " "; } catch(const invalid_argument& e) { cout << "4 " << e.what() << " "; } catch(const exception& e) { cout << "5 " << e.what() << " "; } //catch(const exception& e) { cout << "6 " << e.what() << " "; } catch(const invalid_argument& e) { cout << "7 " << e.what() << " "; } catch(const runtime_error& e) { cout << "8 " << e.what() << " "; } catch(const exception& e) { cout << "6 " << e.what() << " "; } }