Friday 7 March 2014

Exception in C++

Exceptions:-

Class related to " System.Exception" Namespace. it is predefined because System does not class so exception class required.
Exceptions provided run-time error.it is base class error. it is mechanism to solve run-time error.C# is manage to exception error.

Exceptions provide a way to transfer control of a part of a program to another. C + + exception handling is based on three keywords: try, catch, and throw.

  • Throw: A program throws an exception when a problem occurs. This is done using a keyword throw.
  • Catch: A program detects an exception with an exception handler in place in a program where you want to handle the problem. The keyword indicates catch catch exception.
  • try: A try block identifies a block of code for which special exceptions are enabled. It is followed by one or more catch blocks.
Assuming a block raise an exception, a method detects an exception using a combination of opportunity and catch keywords. A try / catch block is placed around the code that might generate an exception. Code within a try / catch block is known as protected code, and the syntax for using try / catch looks like this:


You can list multiple catch statements to catch different types of exceptions in case your try block throws an exception over in different situations below.



0 comments:

Post a Comment