#include <iostream>
#include <string>
using namespace std;
void funk(int i)
{
try
{
switch (i)
{
case 1: throw(string("Have a nice day"));
case 2: throw(5);
case 3: throw(3.14);
}
}
catch(const string& it)
{
cerr << "You threw me a string: " << it << endl;
}
catch(double it)
{
cerr << "You threw me a double: " << it << endl;
}
}
int main()
{
funk(1);
funk(2);
funk(3);
cout << "End of program\n";
return 0;
}
***** Output *****
You threw me a string: Have a nice day Abnormal program termination