c++ exception

C++ Exception

some peculiar problems other than logic or syntax error are known as C++ exceptions.

Exceptions error are run-time anomalies or unusual  condition that a program may enchanter while executing.

Anomalies  night include condition such as division by ‘0’, access to an array outside of its bounce or  running out of memory or disk space .

Types of c++ exceptions

There are two types of exception

  1. Synchronous exception
  2. Asynchronous exception


Synchronous  exception

 Errors such as out of range index and over flow belong to the synchronous type exception.

Asynchronous  exception

The errors that are lost by event beyond the  …….. of the program such as key board interrupt are called  asynchronous.

Exception handling mechanism

C++ exception  handling mechanism is basically built upon 3 key words namely

  1. Try
  2. Throw
  3. Catch


 The keyword try is used to preface a block of statement which may generate exceptions.

Dis-block of statements is known as try block.


 When an exception is detected it is thrown using a throw statement in the try block.



 A catch block defined by the key word catch catches    the  exception thrown by the throw statement in the try block and handles it appropriately.