// bad_alloc3.cc #include using namespace std; int main() { try { int* p = new int[-10]; p[0] = 42; delete[] p; } catch (std::bad_alloc& ex) { cout << "Bad allocation occurred: " << ex.what() << endl; } catch (std::exception& ex) { cout << "Some standard exception occurred: " << ex.what() << endl; } catch (...) { cout << "Some exception occurred" << endl; } }