#ifndef COOKIEH #define COOKIEH #include using namespace std; class cookie { static const size_t n = 1000; //can allocate this many cookies static char buffer[]; static bool b[n]; //true if this slot is currently allocated int i; public: cookie(int initial_i): i(initial_i) { cout << "construct cookie " << i << "\n"; } cookie(): i(0) { cout << "default construct cookie " << 0 << "\n"; } ~cookie() {cout << "destruct cookie " << i << "\n";} void *operator new(size_t); void operator delete(void *p); }; #endif