This is something about exceptions and exception handling in C++.
An exception occurs when we try for an invalid operation. In our code, we will put the code with chance of an illegal operation in a try block. When an illegal operation occurs, it will throw an exception which can be caught by the OS(for that we have to provide exception handling code).

This is a simple divide by zero catcher program.
#include <iostream>
using namespace std;

class Divide
{
public:
class DivideError /*Exception handler class. The constructor is called when throws an exception */
{
};
float divide(int x, int y)
{
if (y == 0)
throw DivideError(); /*Divide by zero is not permitted. So constructor of DivideError class is called */
else
return x/y;
}
};

int main()
{
int x, y;
Divide d;
cout << "Enter 2 numbers : " ;
cin >> x >> y ;
try
{
float f = d.divide(x,y);
cout << f << endl ;
}
catch(Divide:ivideError) /* Works if an exception is thrown from the object */
{
cout << "Division by zero is not possible" << endl ;
}
return 0;
}