home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / code / bcpp / file19 / rangeerr.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-19  |  662 b   |  19 lines

  1. //////////////////////////////////////////////////////////////
  2. // rangeerr.cpp: Here is a sample file showing you how to 
  3. // allocate and set an out-of-range error handler for your 
  4. // arrays.
  5. // Copyright (c) 1993 Azarona Software. All rights reserved.
  6. //////////////////////////////////////////////////////////////
  7. #include <iostream.h>
  8. #include <process.h>
  9. #include "range.h"
  10.  
  11. unsigned (*HandleRangeErr)(unsigned i, unsigned sz) = DefaultRangeErrHandler;
  12.  
  13. unsigned DefaultRangeErrHandler(unsigned i, unsigned sz)
  14. {
  15.   cout << "Subscript " << i << " out of range (0, " << (sz-1) << ")\n";
  16.   exit(1);
  17.   return 0; // Not used in this function
  18. }
  19.