catching exception fail in linux

hi everybody.
i have a problem with linux exception handler.
i use this method:

1
2
3
4
5
6
7
8
9
10
double p() throw(){
    throw 4;
}
...
try{
    p();
} catch (int a) {
    cerr << "sth" << endl;
}
...

but in output i watch this error

terminate called after throwing an instance of 'int'
Aborted


anybody can help me?
Can you post a complete example.
With throw() you declare that the function does not throw any exceptions and yet you do throw one.
So you shouldn't be surprised that things don't go according to plan.
you promised NOT throw any exception in p() by write throw(),however,u did throw a exception,so by default,the global method terminate() will be called to terminate the program 'cause you violate your promise^_^.
Topic archived. No new replies allowed.