Presentation is loading. Please wait.

Presentation is loading. Please wait.

EXCEPTION HANDLING ► COURSE : MSc Computers and Network engineering. ► Name : Kirthidhar Gandham ► Module : Object Oriented Methods (16-7213) ► Module.

Similar presentations


Presentation on theme: "EXCEPTION HANDLING ► COURSE : MSc Computers and Network engineering. ► Name : Kirthidhar Gandham ► Module : Object Oriented Methods (16-7213) ► Module."— Presentation transcript:

1 EXCEPTION HANDLING ► COURSE : MSc Computers and Network engineering. ► Name : Kirthidhar Gandham ► Module : Object Oriented Methods ( ) ► Module Leader : Prof. Alan goude ► Deadline date : 3/04/08 ► Student id :

2 Before lets get talking about the concept of exception handling in c++ let us discuss some topics like what is an exception why we use exception handlers in c++ What are different types of exceptions and what are the keywords that we use for exception handling mechanism

3 What is an Exception? When we write a simple c++ program the first thing that we see when a program doesn’t work correctly are bugs most common bugs are logical errors and syntactic errors but we can overcome these bugs by debugging but sometimes we come across some problems other than logical or syntax errors. These are known as Exceptions.

4 Exceptions are unusual conditions which occur at runtime like low disk space, division by zero, access to array outside its bounds to overcome these anomalies Exception handling concept plays a major role in c++ Exceptions are of two types they are synchronous exceptions and asynchronous exceptions errors like out of range index or overflow come under synchronous exceptions and errors which are beyond the program like keyboard interrupts are called as asynchronous exceptions

5 Exception handling performs the following tasks Finding the problem (Hit the exception). Finding the problem (Hit the exception). Inform an error is occurred (Throw an exception). Inform an error is occurred (Throw an exception). Receive error information (Catch the exception). Receive error information (Catch the exception). Correct it (Handle the exception). Correct it (Handle the exception).

6 The keywords which are mainly used for exception handing mechanism are try, throw and catch. Usually exceptions are thrown by functions which are invoked from try blocks and the point at which the “throw” is executed is called throw point. Once an exception is thrown to catch block, control cannot return to throw point. General format code for this is {………… throw(object); //throws exception ……}……..try{ ……. //invoke function } catch(type arg)//catches exception ……… ………. //handles exception }

7 These are the basic steps to write a c++ program using exception handling mechanism the program which shows the code is attached to this power point presentation separately in a word document.

8 References: Lecture notes given in class and examples given in module site. Lecture notes given in class and examples given in module site. Object oriented programming through c++ by B.chandra. Object oriented programming through c++ by B.chandra. C++ how to program by paul dietel and harvey dietel. C++ how to program by paul dietel and harvey dietel. C++ A beginners guide by herbert schildt. C++ A beginners guide by herbert schildt. The c++ standard library by nicolai M josuttis. The c++ standard library by nicolai M josuttis.


Download ppt "EXCEPTION HANDLING ► COURSE : MSc Computers and Network engineering. ► Name : Kirthidhar Gandham ► Module : Object Oriented Methods (16-7213) ► Module."

Similar presentations


Ads by Google