First page Back Continue Last page Graphics

fig13_02.cpp (2 of 2)

  • 30
  • 31 cout << "This also should not print\n";
  • 32
  • 33 } // end function throwException
  • 34
  • 35 int main()
  • 36 {
  • 37 // throw exception
  • 38 try {
  • 39 cout << "\nmain invokes function throwException\n";
  • 40 throwException();
  • 41 cout << "This should not print\n";
  • 42
  • 43 } // end try
  • 44
  • 45 // handle exception
  • 46 catch ( exception &caughtException ) {
  • 47 cout << "\n\nException handled in main\n";
  • 48
  • 49 } // end catch
  • 50
  • 51 cout << "Program control continues after catch in main\n";
  • 52
  • 53 return 0;
  • 54
  • 55 } // end main