// File: eh5.cpp - exception handing style, where to place the try
#include <iostream>
void funk(int up)
{
try
{
throw up;
}
catch(int up)
{
std::cout << "I caught a " << up << std::endl;
}
return;
}
int main()
{
for (int up = 1; up <= 5; up++)
{
try
{
throw up;
}
catch(int z)
{
std::cout << "You threw me a " << z << std::endl;
}
}
for (int i = 6; i <= 10; i++) funk(i);
std::cout << "End of program\n";
return 0;
}
***** Output *****
You threw me a 1 You threw me a 2 You threw me a 3 You threw me a 4 You threw me a 5 I caught a 6 I caught a 7 I caught a 8 I caught a 9 I caught a 10 End of program