// File; Alloc.cpp // Catch allocation exceptions #include #include using namespace std; int main() { int *p, i; int num; cerr << "How many ints to allocate? >"; cin >> num; try { p = new int[num]; // allocate memory for num-element int array } // bad_alloc is built-in C++ exception catch (bad_alloc xa) { cout << "Allocation failure.\n"; return 1; } for(i = 0; i