SCSI Hard Drives
Search
Advanced Search

Categories


Recently Viewed
Pages



My Links
Web Directory Index
A human edited, comprehensive web directory list.
Link Exchange
DesignFirms Link Exchange


Exception Handling in C++

By : sterex
Rating : Average Rating : 2.00 From 1 Voter(s)


 


The three keywords throw, try and catch are used to handle exceptions. Function returning using the exception handling mechanism is referred to as throwing an exception. The keyword throw is used to throw an exception. Try keyword surrounds a block of statements which may generate exception. Catch block catches the exception thrown by throw and handles them appropriately. The general forms of try and catch are shown above.



Example
try{
// try block
}
catch (type 1 arg){
// catch block
}
catch (type2 arg){
// catch block
}
catch (type3 arg){
// catch block 
}


 


The relationship between the three words try, catch and throw is shown in the figure. The try block code normally invokes a function that detects an exception. The function which is in the throw block returns the control to the catch block. There can be many catch blocks, each corresponding to a particular type of exception. The function throwing an exception indicates the specific type of exception which in turn decides the catch statements to be executed.


 


 


schematic







Comments / Feedback

RSS 2.0: Syndicate this article

Add Comment
* Name


* Email Address


Site



*Image Validation (?)


*Comments / Feedback





Print Article Print Article Send to a friend Send to a friend Save as PDF Save as PDF Social Bookmarking
Add to: Mr. Wong Add to: Webnews Add to: Icio Add to: Oneview Add to: Folkd Add to: Yigg Add to: Linkarena Add to: Digg Add to: Del.icio.us Add to: Reddit Add to: Simpy Add to: StumbleUpon Add to: Slashdot Add to: Netscape Add to: Furl Add to: Yahoo Add to: Spurl Add to: Google Add to: Blinklist Add to: Blogmarks Add to: Diigo Add to: Technorati Add to: Newsvine Add to: Blinkbits Add to: Ma.Gnolia Add to: Smarking Add to: Netvouz Information
Rate this Article :

1

2

3

4

5

6

7

8

9

10
Poor Excellent