- It is possible that a program segment has more than one condition to throw an exception.
- For these situations we can associate more than one catch statement with a try block.
- When an exception is thrown, the exception handlers are searched in order for an appropriate match.
- The fist handler that yields a match is executed.
- After executing the handler, the control goes to the first statement after the lat catch block for that try.
Note: It is possible that arguments of several catch statements match the type of an exception.
In such cases, the first handler that matches the exception type is executed.
using namespace std;
void test(int x)
cout<<"Caught a character"<<endl;
cout<<"Caught an integer"<<endl;
cout<<"Caught a double"<<endl;
cout<<"End of the try catch system"<<endl;
out<<"Testing multiple catch"<<endl;