try with multiple catch
#include "stdafx.h"
#include <iostream>
#include<string>
using namespace std;
int main ()
{
// try with multiple catch blocks
try
{
throw 20; // Catch block having the same type of argument will catch the function.
}
catch (int e)
{
cout << "An exception occurred. Exception Number: " << e ;
}
catch (char e2)
{
cout << "An exception occurred. Exception Type: " << e2 ;
}
return 0;
}
Output:
An exception occured. Exception Number: 20