C++ Exception handling

C++ Exception handling

we know that is very rare that a program works correctly first time . It might have bugs. The two most common types of bugs are logic error and syntactic errors. The logic errors occurs due to poor understanding of the problem and solution procedure. The syntactic problems or errors arise due to poor understanding of the language itself.we can detect these errors by using exhaustive debugging and testing procedures

We often come across some peculiar problems other than login or syntax errors. They are known as exception. Exception are run time anomalies or unusual conditions that a program may encounter while execution. Anomalies might include conditions such as division by zero , access the array outside of its bounds or size, or running out of memory or disk space, when a program encounters an exceptional condition. It is very important that it is identified and dealt with effectively ANSI C++ language provides built in language features to detect and handled exception which are basically run time errors.

the EXCEPTION handling is not a part of c++, it is a new feature added to ANSI c++ today , almost all compilers support this feature.in C++ language the exception handling provides a type safe integrated approach for coping with the unusual predictable problems that arise while executing a program.

BASIC OF EXCEPTION HANDLING

Exception are two kinds,namely, synchronous exceptions and asynchronous exceptions.Error such as “out of range index” and “over flow” belongs to the synchronous type exceptions. The error that are caused by the events beyond the control of program(such as keyboard interrupts) are called asynchronous exceptions. The proposed exception handling mechanism in c++ language is designed to handled only synchronous exceptions.

The purpose of the exception handling is to provide means to detect and report an “Exceptional circumstance” so that appropriate action can be taken. The mechanism suggests a separate error handling code that performs step by step the following tasks

1. Find the problem (Hit the exception)
2. inform that an error has occurred (Throw the exception)
3. Receive the error information(catch the exception)
4. Take corrective actions(Handled the exception)

The error handling code basically consists of two segments, one to detect errors and to throw exceptions, and the other to catch the exceptions and to take appropriate actions

  • C++ Dynamic Initialization of Objects
  • C++ Copy Constructor
  • C++ Dynamic Constructor
  • C++ Destructors
  • C++ Exercise
  • C++ Operator Overloading
  • C++ Overloading Unary Operators
  • Const pointer in C
  • Void pointer in c
  • C++ Overloading Binary Operators
  • C++ Overloading Binary Operators Using Friends
  • C++ Manipulation String Using Operators
  • C++ Rules for overloading operators
  • C++ Exercise
  • C++ Basic To class Type
  • C++ Class TO Basic Type
  • C++ One class To another class type
  • C++ Exercise
  • C++ Inheritance introduction
  • C++ Single Inheritance
  • C++ Multiple Inheritance
  • C++ Ambiguity Resolution in inheritance
  • C++ Hierarchical Inheritance
  • C++ Hybrid Inheritance
  • C++ Virtual Base Classes
  • C++ Exercise
  • C++ abstract class
  • C++ nesting of classes
  • C++ Exercise
  • C++ polymorphism
  • C++ Exercise
  • C++ pointers
  • C++ Pointers TO object
  • C++ this pointer
  • C++ Pointer to Derived class
  • C++ Virtual functions
  • C++ Exercise
  • C++ streams
  • C++ unformatted I/O operations
  • C++ Put() and get()
  • C++ getline() and write()
  • C++ Formatted console I/O
  • C++ Manipulators
  • C++ Exercise
  • C++ file handling
  • C++ file stream classes
  • C++ Open and closing file
  • C++ open using constructor
  • C++ open using open()
  • C++ Detecting End of file
  • C++ File modes
  • C++ File pointers and Manipulators
  • C++ Sequential I/O
  • C++ Reading and Writing
  • C++ Updating a File
  • C++ Error handling In File
  • C++ Command Line Arguments
  • C++ Exercise
  • C++ Template introduction
  • C++ Class Templates with multiple Parameters
  • C++ Function templates
  • C++ Function templates with multiple parameters
  • C++ member function Template
  • C++ Exercise
  • C++ Exception handling
  • C++ Basics of Exception Handling
  • C++ Exception Handling Mechanism
  • C++ Throwing Mechanism
  • C++ Catch Mechanism
  • C++ Catch all Exceptions
  • C++ Re-Throwing An Exception
  • C++ Specifying Exceptions
  • C++ Exercise