#include<iostrearn>
using namespace std;
void subtract(int p, int q) //A function called subtract
with two arguments is defined
{
cout<<"The subtract() function contains\n";
try //try block1
{
if(p==0) //This condition checks whether p is equal to zero
or not.
//if yes throw an exception else perform subtraction
throw p; //This statement throws an exception
else
cout<<"The result of subtraction is:"
<<p-q<<"\n";
}
catch(int) //This statement catches the exception throw it
again to the next try block
{
cout<<"NULL value is caught\n";
throw;.
}
cout<<."End of subtract()\n\n";
}
int main( )
{
Cout<<"\n The main() function
contains\n";
try
{
subtract(5, 3); //passing integer values to subtract
subtract(0, 2);
}
catch(int) //This statement catches the rethrown
exception
{
cout<<"NULL value caught inside
main()\n";
}
cout<<End of main() function \n";
return 0:
}
![Rethrowing an Exception example examples of Rethrowing an Exception in c++,c++ notes unitwise,oops using c++ notes jntuh unitwise,use of Rethrowing an Exception in c++,programs for Rethrowing an Exception in c++](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-X8uwmVOdWLYtb-Clj_lbzJwCJCbs3JVpdpERk4m2jKR9t6Ng9eM0Rwbf9DDdq6noU_SwBCpVWuVw_EqcpSx1Ld5VB4IMlvjQ5u38u16Uk1ubx5eJZnemvNO2BA54Ss9aPhpoggn5iSs/w640-h164/image.png)