     xailoc      xmsg,    
  EXCEPT.H.  -     
string (     ).     ,  
       catch,   
- why().       
      x.requested(). 
          try   main()   
  . ,   main()   
 :   

    void main()	
    {	.                            . 
       for (;;) {  
          try { 
            Run();	//   
         } 
          catch (xailoc x) { 
            cout  "Out of memory"  endl; 
            exit(-1);        //       
         } 
     }
  }

             Run(), 
 .       
 Run() (   ,   Run())    
main(),         catch. 
      15.19    MEMERR   12, 
       new 
 ""    .     
    DOS-  Easy Win-. 

     

      MEMERR    ,    
         .  
  ,  MEMERR       DOS, 
Windows   . (     
.)   ,     
.       . 


     15.19. MEMERR.CPP (    new) 

    1:	#include <iostream.h> 
    2:	#include <new.h> 
    3:	#include <except. h> 
    4:	#include <cstring.h> 
    5:	#include <stdlib.h>	
    6: 
    7:	struct q { 
    8:	  int ia[1024];	// 2048-  
    9:	}; 
    10: 
    11:	char *pool;	//     
    12: 
    13: 	int main() 
    14:	{	
    15:	 struct q *qp;	//    q 
    16: 
    17:	try {	
    18: 	   pool = new char[512]; 	//             
    19:	}
    20:	catch (xalloc) {	
    21:	  cout  "Not enough	RAM to run program"  endl;   
    22:	  exit(-1); 
    23:	} 
    24: 
    25:	for (;;) {	//    " " 
    26:	  try {	//  try     
    27:	     qp = new q;	//     q 
    28:	      cout  qp  '\n	';//    
    29:	  } 
    30:	 catch (xailoc x) {	//     new  
    31:	   delete pool;	//                  
    32:	   cout  "Error: "	 x.why()  endl; //       
    33:	   exit(-1);	//   (  ) 


    418      III.   ANSI C++ 
