home *** CD-ROM | disk | FTP | other *** search
- // \EXAMPLES\EX1602.CPP
-
- //----------------------------------------------------------
- // Exception handling is supported only by
- // the IBM C Set++ Compiler
- // This example does not work in Borland Turbo C++
- // or in Microsoft Visual C++
- //----------------------------------------------------------
- // To run this program on an OS/2 machine:
- // move to an OS/2 window
- // [type] cd:\EXAMPLES\EX1602I
- // where cd: is the drive of the CD-ROM
- //----------------------------------------------------------
-
- #include <iostream.h>
-
- //
- // This is an example of nested try blocks
- //
- void main()
- {
- try // outer try block
- {
- try // nested try block
- {
- float x = 1;
- throw( x); // something went wrong
- }
- catch( char y) // nested try block exception handler
- {
- cout << "The nested eception handler caught the exception"
- << endl;
- }
- }
- catch( float x) // outer try block exception handler
- {
- cout << "The outer exception handler caught the exception"
- << endl;
- }
- }
-