#include <iostream>
void fun(int test) {
cout << "Inside fun, test is: " << test << "\n";
if(test)
throw test;
}
int main() {
cout << "start\n";
try {
cout << "Inside try block\n";
fun(0);
fun(1);
fun(2);
}
catch (int i) {
cout << "Caught an exception -- value is: ";
cout << i << "\n";
}
cout << "end";
return 0;
}
|