home *** CD-ROM | disk | FTP | other *** search
/ Microsoftware Monthly 19…2 Programming Power Tools / MASO9512.ISO / cpptutor / cpptutor.arj / EXAMPLES / EX1601.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-24  |  1.1 KB  |  37 lines

  1. // \EXAMPLES\EX1601.CPP
  2.  
  3. //----------------------------------------------------------
  4. //  Exception handling is supported only by
  5. //                            the IBM C Set++ Compiler
  6. //  This example does not work in Borland Turbo C++
  7. //                          or in Microsoft Visual C++
  8. //----------------------------------------------------------
  9. //  To run this program on an OS/2 machine:
  10. //                      move to an OS/2 window
  11. //              [type]  cd:\EXAMPLES\EX1601I
  12. //                      where cd: is the drive of the CD-ROM
  13. //----------------------------------------------------------
  14.  
  15. #include <iostream.h>
  16.  
  17. void main()
  18. {
  19.    // This is a try block
  20.    try
  21.    {
  22.       throw( float(1));
  23.    }
  24.    // This char exception handler won't catch the exception
  25.    catch( int y)
  26.    {
  27.       cout << "The value of the char exception was: "
  28.            << y << endl;
  29.    }
  30.    // This float exception handler will catch the float exception
  31.    catch( float x)
  32.    {
  33.       cout << "The value of the float exception was: "
  34.            << x << endl;
  35.    }
  36. }
  37.