Home > DeveloperSection > Blogs > Exception Handling in C++

Exception Handling in C

.NET Visual C++ 
0 Comment(s)
 565  View(s)
Rate this:

Exception Handling in C++

In this blog, I’m explaining about Exception handling in C++


An  exception  is a problem that arises during the execution of a program Exceptions provide a way to transfer control from one part of a program to another.

C++ exception handling is built upon three  keywords: _try, catch and throw.

throw: A program throws an exception when a program show up. This is done using a throw keyword.

try: A try block identifies a block of a code for which particular exceptions will be activated. It’s followed by one or more catch blocks.

catch: A program catches an exception  with  an exception handler at the place in a program where you want to handle the problem. This is done using a catch keyword.


// Exception.cpp : main project file.


#include "stdafx.h"

#include <iostream>

#include <exception>

#include <Windows.h>

using namespace std;

using namespace System;


int main(array<System::String ^> ^args)




                        int firstNum,secNum,res;

                        cout<<"Enter first number";


                        cout<<"Enter second number";









                        cout<<"InValid data";



    return 0;


Don't want to miss updates? Please click the below button!

Follow MindStick