C++ : Exception Handling Part 1

1. Explain Exception Handling & its use.

2. Explain the [try,catch & throw]

3. Example showing the use of Exception handling.


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

#include

using namespace std;

void testException()
{
int rel;

cout<>rel;

try
{
if(rel<=0)
{
throw(rel);
}
else
{
cout<<“\nThe value is:”<<rel;
}
}
catch(int val)
{
cout<<“\n——-Exception occured——-“;
}
}

int main()
{
testException();

return 0;
}

Advertisements

Leave a comment

Filed under C++, Exception Handling

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