/*multiple catch exception
**************************/
/*multiple catch statments used when the user want to handle different exception
differently. for this user must declear different catch statments with different
declerations.*/
#include<iostream>
using namespace std;
int main()
{
int num;
start:
cout<<"please enter the number:";
cin>>num;
try
{
if(num>0)
{
throw num;
}
else if(num<0)
{
throw 'x';
}
else
{
throw 2.54;
}
}
catch(int i)
{
cout<<"catch the integer value:"<<endl;
goto start;
}
catch(char u)
{
cout<<"catch the character:"<<endl;
goto start;
}
catch(double d)
{
cout<<"catch the double value:"<<endl;
goto start;
}
}
No comments:
Post a Comment