#include <iostream>
using namespace std;
void find(int x)
{
try
{
if(x==1)
throw x;
else
if(x==0) throw 'p';
else
if(x==-1) throw 1.0;
cout<<" NO Exception " << "X value " << x;
cout<<"\n End of try block\n ";
}
catch(...)
{
cout << "Caught an Exception \n";
}
}
int main()
{
cout<<" Testing of Generic Catch \n";
find(0);
find(1);
find(-1);
find(10);
return 0;
}
output:
Testing of Generic Catch
Caught an Exception
Caught an Exception
Caught an Exception
NO Exception X value 10
End of try block
0 Comments
Post a Comment