Exception Handling Mechanism in C++
-> C++ exception handling mechanism is basically built upon 3 keywords namely try, throw and catch.
-> The keyword try is used to preface a block of statements which may generate exceptions. This block of statement is known as try block.
-> When an exception is detected, it is thrown using throw statement int the try block.
-> A catch block defined by the keyword catch , catches the exception thrown by the throw statement int the try block and handles it appropriately.
A catch block that catches an exception must immediately follow the try block that throws the exception.
-> C++ exception handling mechanism is basically built upon 3 keywords namely try, throw and catch.
-> The keyword try is used to preface a block of statements which may generate exceptions. This block of statement is known as try block.
-> When an exception is detected, it is thrown using throw statement int the try block.
-> A catch block defined by the keyword catch , catches the exception thrown by the throw statement int the try block and handles it appropriately.
A catch block that catches an exception must immediately follow the try block that throws the exception.
Try
Block
|
Detect
and throw
An exception
|
Exception
Object
Catch
Block
|
Catches
and handles the exception
|