Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
Exception Handling in C++

Exception Handling in C++

Ratings: (0)|Views: 79|Likes:
Published by Anik
Exception Handling in C++
Exception Handling in C++

More info:

Published by: Anik on May 20, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as RTF, PDF, TXT or read online from Scribd
See more
See less

06/20/2013

pdf

text

original

 
Exception HandlingIt is a built in error handling mechanism. Against traditionalerror handling mechanism, usingexception handling, exceptionalsituations can be handled in easierand better way.The exception handling is builtupon three keywordsThe try keyword: It appears at the place where measures to be taken onerrors occured. Thestatements/method calls which areto be monitored for exceptions arecontained in try block.The catch keyword: If statementswritten in try block eventuallythrow exception, control isimmediately sent to matching catch block. A catch block should contain statements to take measureon the exception occured. Aftercatch block, program resumesexecution from the statementfollowed by last catch block.
 
The throw statement: A statementwhich should be executed when anexceptional situation occurs.// Prog 01// Illustrating ry-catch-throw#include<iostream> using namespace std; void main(){cout <<"start"<<endl;try{cout <<"inside try block:"<<endl;throw 10;cout <<"this will notexecute:";}catch(int i){cout <<"caught One ! numberis ";cout <<i <<endl;}
 
cout <<"end";}---------------------------------------------------------------------// Prog 02#include<iostream> using namespace std; void main(){cout <<"start"<<endl;try{cout <<"inside try block:"<<endl;throw 10;cout <<"this will notexecute:";}catch(int i){cout <<"caught One ! numberis ";cout <<i <<endl;}

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->