    23:	void zapper(); 
    24: 
    25:	//       Error 
    26:	int Error::count; 
    27: 
    28:	void main()
    29:	{ 
    30:	  set_unexpected(trapper); 
    31:	  set_terminate(zapper); 
    32:	  for (;;) 
    33:	  { 
    34:	     try { 
    35:	       Run(); 
    36:	     } 
    37:	     catch (Error e)  { 
    38:	        e.Say(); 
    39:	     } 
    40:	  } 
    41:	} 
    42: 
    43:	// ,    
    44:	void Run() throw(Error) 
    45:	{ 
    46:	   // throw ErrorO; 
    47:	   throw "An unknown exception object"; 
    48:	} 
    49: 
    50:	//     
    51:	void trapperQ 
    52:	{ 
    53:	  cout  endl  "Inside trapper function"  endl; 
    54:	  throw Error(); 
    55:	} 
    56: 
    57:	//     
    58:	void zapper() 
    59:	{ 
    60:	  cout  endl  "Inside terminate function"  endl; 
    61:	  cout  endl  "Exiting program with error code -1"  endl; 
    62:	  exit(-1); 
    63:	} 
    64: 
    65:	//   Error 
    66:	Error: :Error() 
    67:	{ 
    68:	  count++; 
    69:	  if (count > MAXERR) 
    70:	     throw MaxError(); 
    71:	} 
    72: 
    73:	//   Error,   
    74:	void Error::Say() 
    75:	{ 
    76:	  cout  "Error: count = "  count  endl; 
    77:	}
 
      UNEXPECT       
.  . 15.3    . 
          .   
,     , ,    
  MAXERR,      10.   
Error   ,     . 
      Error,     , 
.   count.   count  
,      ,    
  ,    .   count  ,  
          
.  -  Error     
  . - Say()    count. 
          Error,   count    
 MAXERR,      
.        , 
    Error  (     
 ). 


     15.   C++     413 
