home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / cdactual / demobin / share / program / C / ANSICPP.ZIP / EX03005.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-24  |  427 b   |  24 lines

  1. // ex03005.cpp
  2. // free store exhaustion and the _new_handler function
  3. #include <iostream.h>
  4. #include <stdlib.h>
  5.  
  6. static void all_gone()
  7. {
  8.     cerr << "\n\aThe free store is empty\n";
  9.     exit(1);
  10. }
  11.  
  12. extern void (*_new_handler)();
  13.  
  14. main()
  15. {
  16.     _new_handler = all_gone;
  17.     long total = 0;
  18.     while (1)    {
  19.         char *gobble = new char[10000];
  20.         total += 10000;
  21.         cout << "Got 10000 for a total of " << total << '\n';
  22.     }
  23. }
  24.