Program:
#include<iostream.h>
#include<conio.h>
void test(int x) throw(int,double)
{
if(x==0) throw 'x';
else
if(x==1) throw '10';
else
if(x==-1) throw '2.7';
cout<<"End of function block\n";
}
void main()
{
try
{
cout<<"Testing throw restrictions\n";
cout<<"x==0\n";
test(0);
cout<<"x==1\n";
test(1);
cout<<"x==-1\n";
test(-1);
cout<<"x==2\n";
test(2);
}
catch(char c)
{
cout<<"Caught a character\n";
}
catch(int m)
{
cout<<"\nCaught an integer\n";
}
catch(double d)
{
cout<<"Caught a double\n";
}
cout<<"\nEnd of try-catch system\n\n"
}