#include #include using namespace std; void foo() { overflow_error oops("We overflowed, honest!"); throw oops; } // logic_error is-a exception // runtime_error is-a exception int main() { try { foo(); } catch (const logic_error &e) { cout << "Caught a a logic_error: " << e.what() << '\n'; } catch (const runtime_error &e) { cout << "Caught an runtime_error: " << e.what() << '\n'; } catch (const exception &e) { cout << "Caught an exception: " << e.what() << '\n'; } return 0; }