// File: eh8.cpp
#include <iostream>
#include <string>
using namespace std;
void funk(int i)
{
try
{
switch (i)
{
case 0: throw(0);
case 1: throw(string("Have a nice day"));
case 2: throw(5);
case 3: throw(3.14);
}
}
catch (const string& it)
{
cout << "You threw me a string: " << it << endl;
}
catch(const char* it)
{
cout << "You threw me a const char*: " << it << endl;
}
catch(double it)
{
cout << "You threw me a double: " << it << endl;
}
catch(...)
{
cout << "You threw me something. I know not what!\n";
}
}
int main()
{
funk(1);
funk(2);
funk(3);
funk(0);
cout << "End of program\n";
return 0;
}
***** Output *****
You threw me a string: Have a nice day You threw me something. I know not what! You threw me a double: 3.14 You threw me something. I know not what! End of program