#include #include #include using namespace std; void my_new_handler(); const char *progname; //uninitialized variable int main(int argc, char **argv) { progname = argv[0]; set_new_handler(my_new_handler); cout << "How many char's do you want to allocate? "; size_t n; cin >> n; //portable char *const p = new char [n]; p[0] = 'A'; p[1] = 'B'; p[2] = 'C'; //etc. p[n - 1] = '\0'; //Warning: subscripts only go up to n - 1. cout << "The hidden numbers are " //unofficial << reinterpret_cast(p)[-2] << " and " << reinterpret_cast(p)[-1] << ".\n"; delete[] p; return EXIT_SUCCESS; } void my_new_handler() { cerr << progname << ": out of store\n"; exit(EXIT_FAILURE); }