     12.10 ,   new     
,   ,  ,     
 .        
EasyWin-         DOS. 
      "Unreachable code" 
( ). (   ,     
 .) 

     12.10.  MEHERR.CPP ( new  ,    
 ) 

    1:	#include	<iostream.h> 
    2:	#include	<new.h> 
    3:	#include	<stdlib.h> 
    4: 
    5:	struct q	{ 
    6:	  int ia[1024]; // 2048-  
    7: 	};
    8.	 
    9:	main() 
    10:	{ 
    11:	struct q	*qp; //    q 
    12: 
    13:	set new handler(O); //  new      
    14:	for (;;)  { //    " " 
    15:	   qp = new q; //     q 
    16:	   cout 	qp,  ' \n ' ; //,    
    17:	   if (qp == 0) { //    new 0 : 
    18:	      cout  "Out of memory\n"; //     
    19:	     exit(1);	//      1 
    20:	  } 
    21:	} 
    22:	return 0	;//      "unreachable code" 
    23:	}
 
          5-7    
 1,024  .     new  
2,048-  (  ,      
).     ,    
 , ,  ,  new     . 
     new     ,   0  
set_new_handler().   ""  for   
.     new   2048-   
    qp.     , 
  qp.  qp  ,   ,  new    
 ,         
      exit().     
     (    ,   
   ): 

    0x1366 
    0x18 
    ...........
    0x0000 
    Out of memory 

        set_new_handler(), new  
   ,   .   
 ,     set_new_handler(), 
     .   : 

    0x1366 
    0x18 
    .......
    0x0000 
    Abnormal program termination 

          ,   
 ,        exit().  
  new   ,    
 . 

     

       new   ,   
          
 new ,      ,   
   .  ,    ,  
     "Abnormal program tenainatjon" ( 


     12.   C++     291 
