1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <exception> 4 5 static void eh_terminate()6eh_terminate () 7 { 8 printf ("CALLING TERMINATE\n"); 9 exit (1); 10 } 11 12 void eh_test(int level)13eh_test (int level) 14 { 15 try 16 { 17 if (level < 2) 18 eh_test (level + 1); 19 else 20 { 21 printf ("%d: Throwing\n", level); 22 throw (level); 23 } 24 } 25 catch (int &x) 26 { 27 printf ("%d: Got level %d\n", 28 level, x); 29 30 if (level > 0) 31 throw; 32 } 33 } 34 main()35int main () 36 { 37 std::set_terminate (&eh_terminate); 38 eh_test (0); 39 } 40