home *** CD-ROM | disk | FTP | other *** search
/ Using Visual C++ 4 (Special Edition) / Using_Visual_C_4_Special_Edition_QUE_1996.iso / ch13 / rule7.cpp < prev    next >
C/C++ Source or Header  |  1995-09-18  |  444b  |  29 lines

  1. // Get needed include files
  2. #include <iostream.h>
  3. #include <eh.h>
  4.  
  5. void Func1(int flag)
  6. {
  7.     try {
  8.         cout << "In Func1.\n";
  9.         if (flag)
  10.             throw "String exception";
  11.     }
  12.     catch (int) {
  13.         cout << "Caught an integer exception.\n";
  14.     }
  15. }
  16.  
  17. void main()
  18. {
  19.     try {
  20.         Func1(1);
  21.     }
  22.     catch (char *str) {
  23.         cout << "Caught a string exception: " << str << "\n";
  24.     }
  25.     catch (...) {
  26.         cout << "Caught an unrecognized exception.\n";
  27.     }
  28. }
  29.