C++: Exception Handling Part 3

1. Explain Exception Handling.

2. Explain about specifying rethrowing exception.

3. Example showing the use of specifying rethrowing exception in C++.


/*
Developed By: Prof. Vinod Pillai
vinodthebest@gmail.com
Exception Handling-Part 3.
*/

#include

using namespace std;

void testException1() throw(int,char)
{
int val;

cout<>val;

if(val<=0)
{
throw(100);

//throw(‘a’);

//throw(10.56);
}
}

void testException2() throw()
{
int val;

cout<>val;

if(val<=0)
{
throw(100);
}
}

int main()
{
try
{
testException1();

//testException2();
}
catch(int value)
{
cout<<“\n——-Rethrow Integer Exception occured——-“;
}
catch(char value)
{
cout<<“\n——-Rethrow Character Exception occured——-“;
}
catch(…)
{
cout<<“\n——-Rethrow All Exception occured——-“;
}
return 0;
}

Advertisements

1 Comment

Filed under C++, Exception Handling

One response to “C++: Exception Handling Part 3

  1. pavithra

    how to download this video

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s