home *** CD-ROM | disk | FTP | other *** search
- // \EXAMPLES\EX1601.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\EX1601I
- // where cd: is the drive of the CD-ROM
- //----------------------------------------------------------
-
- #include <iostream.h>
-
- void main()
- {
- // This is a try block
- try
- {
- throw( float(1));
- }
- // This char exception handler won't catch the exception
- catch( int y)
- {
- cout << "The value of the char exception was: "
- << y << endl;
- }
- // This float exception handler will catch the float exception
- catch( float x)
- {
- cout << "The value of the float exception was: "
- << x << endl;
- }
- }
-