CS202 5- ‹#›
Detecting an Exception
nTherefore, try blocks establish when exception handling is in effect.
nIf an exception is thrown outside of a try block, terminate is called.
nWhen we are in a try block, we are able to select and handle different types of exceptions. This is called catching an exception.
nThe following demonstrates a try block that "turns on" exception handling for our entire program:
nint main() {
n  try {
n    ...          //program code
n  }
n  ...            //code to handle exceptions
n  cout <<"normal program exit" <<endl;
n  return(0); }
n