+ 1
How to make a multiple exceptions in integer
the program get two values from the user , if v1 less than 0 than throw an exception .. and if v2 is bigger than 50 it will throw an exception , I want any exception have a different catches with integer , but I don't how to do that !
2 Answers
+ 5
try
{
int v1,v2; cin>>v1>>v2;
if(v1<0) throw 1;
if(v2>50) throw 2;
}
catch(int s)
{
switch(s)
{
case 1:
cout<<"Less than 0"; break;
case 2:
cout<<"More than 50"; break;
}
}
+ 1
thanks a lot đ