/*Rethrowing exception in c++
*****************************/
/*where we have an inner and outer try and catch statments then the rethrowing
exception possible.an exception to be thrown from inner catch block to outer catch
block is called rethrowing exception.*/
#include<iostream>
using namespace std;
int main()
{
int num;
cout<<"please enter the number here:";
cin>>num;
try
{
try
{
throw num;
}
catch(int x)
{
cout<<x<<" catch the integer by inner catch-try block:"<<endl;
throw x; //here rethrowing the exception
}
}
catch(int u)
{
cout<<u<<" catch the integer by outer catch-try block:"<<endl;
}
}
No comments:
Post a Comment