#include #include #include #include "obj.h" 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 obj's do you want to allocate? "; size_t n; cin >> n; obj *const p = new obj [n]; //Call the default constructor n times. for (size_t i = 0; i < n; ++i) { cout << p[i] << "\n"; } cout << "The hidden numbers are " //unofficial << reinterpret_cast(p)[-3] << ", " << 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); }