2026-06-29 21:18:48 +02:00

18 lines
650 B
C++

#include <iostream>
#include <stdexcept>
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() << " "; }
}