Mainly errors are classified into two categories:
Compile time error:
These are the error which occurs whenever you compile the program. We can't continue further until we remove the errors. Some compile time errors are:
· Missing semicolon
· Missing double quotes in string
· Use of undeclared variable
· Missing curly braces({ })
Runtime error:
With runtime error the compiler doesn't produce any error but result produce by program may be incorrect or some output is produced again and again without stopping or no output is produced. Different type of runtime errors are:
· Divide by zero
· Try to store or use an array that is out of bound
· Using an infinite loop without break statement
An exception is a condition that is caused by a runtime error in the program. If we want to execute the remaining code excluding the errors, then you should catch the exception object given by the error condition & then display an appropriate message. This process is known as exception handling.
Try-catch block:
The exception handling allows one section of a program to serve and dispatch error condition and another section to handle them. These two sections or blocks are represented by try and catch.
Syntax:
Refer to the picture for syntax!
Throw statement:-
To detect an exception and jump to a catch handler, a C++ function uses the throw statement with the data type that matches the parameter list of proper catch handlers.
Example: throw "An error has occurred".
If we want to divide two numbers and an error will occur when we divide a number by zero for this the program will be like this:
Refer to the picture for the program!
So the exception handling mechanism performs the following tasks:
· Hit the exception or Find the problem
· Throw the exception
· Catch that exception and,
· Handle the exception
If a program has more than one condition to throw an exception than more than one catch statement with try can be used.
Published by Harsh Gupta - Tech Writer
I am a part time freelancer and writing is my hobby Some of my websites: http://www.GenericArticles.com http://www.JailBreakingiPhone.com View profile
- Plus Size Fashion Designers to AdmireDo you ever wonder who designed the clothes you wear? Getting to know the inspirations behind your clothes will make you cherish them more. Here we take a closer look at 3 unique plus size fashion designers, and where...
Review of the Pledge Duster PlusA review of the new Pledge Duster Plus with multi purpose spray. Will it perform as it's advertised to? Does it really clean any surface?- How to Shop for Plus Sized Women's ClothingFor Plus Size Women - How to Dress to Look Your Best. In this article we'll explore some hints and tips for how to buy the right clothes to compliment your plus sized frame.
- Embracing Fashion as a Plus Size WomenFashion is changing our perceptions about weight and beauty. As a plus size woman, learn to embrace your beauty and express your bodily image through fashion proudly.
- Plus Size Teen Clothing StoresIf you are a plus sized teen you may find it frustrating to shop and find 'cool and hip' clothing. Here I will show you a few online clothing stores and a few nationwide clothing stores that specialize in plus size te...
- Pert Plus: The Perfect Shampoo for Kids
- Find Great Plus Size Workout Wear
- Shopping for Women's Plus Size Clothing
- Razor Burn is a Thing of the Past - Schick Intuition Plus Razor: A Product Review
- Plus Size Fashion for Teens: An Overview
- Appropriate and Stylish Plus Size Fashion
- Holiday Plus Size Clothing Store Guide
- An exception is a condition that is caused by a runtime error in the program.
- The process of removing errors is called debugging and ways of removing errors as debugging techniqu




