// bad_alloc2.cc #include using namespace std; int main() { try { int* p = new int[-10]; p[0] = 42; delete[] p; } catch (...) { cout << "Some exception occurred" << endl; } }