Because I do not handle the exception?

Hello everyone. I have Windows XP and use as IDE Code::Blocks with MinGW 4.7.
I wrote this simple program to understand exception handling:
divide.h
1
2
3
4
5
6
#ifndef DIVIDE_H
#define DIVIDE_H

int divide( int a, int b ) throw (char *);

#endif // DIVIDE_H 

divide.cpp
1
2
3
4
5
6
7
#include "divide.h"

int divide( int a, int b ) throw ( char * )
{
    if( b ) return a/b;
    throw "Division by zero";
}

main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include "divide.h"

using namespace std;

int main()
{
    cout << "Enter the dividend: ";
    int a; cin >> a;
    cout << "enter the divisor: ";
    int b; cin >> b; cout << endl;
    try
    {
        cout << "The result: " << divide( a, b );
    }
    catch( char *stringa )
    {
        cout << stringa << endl;
        return -1;
    }

    return 0;
}

Running the program and putting as divisor 0, is not handled my exception.
What have I forgotten ?
1) Abstain from using dynamic exception specifications. They are deprecated and are no good anyway.
2) Type of string literal (which you are throwing) is const char*, not char*)
Where can I find a good tutorial that teaches the exceptions to be studied ?
I cannot remember book dedicated solely to exception handling, but there is a whole section on error handling in C++ Coding Standards by Herb Sutter and Andrei Alexandrescu. Some other books by renowned C++ experts sometimes talks about some specific sides of error and exception handling.
Thank you so much for all your explanations
There's a usage summary with some references at http://en.cppreference.com/w/cpp/language/exceptions
Topic archived. No new replies allowed.