How is exception handling carried out in c++?

Showing Answers 1 - 1 of 1 Answers

samiksc

  • Jan 19th, 2006
 

Exception handling is carried out using try, catch blocks and the throw statement.

Try block includes all code which can result into any exception.

It is followed by one or more catch blocks starting from most specific to least specific. A catch block handling exception of a class type can also handle exceptions of any class in its inheritance hierarchy.

A function can declare a throw (....) declaration saying that it is not going to handle exceptions of the specified types. These exceptions will be thrown to the calling function.

If an exception is unhandled the program will have abnormal termination.

try catch blocks can be nested to any level.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions