Hi
I was seeing the behavior of unexpected() function in exception handling.
I was wondering why the function set for un_expected() didn't called when exception was thrown.
Below is the code:
I was expecting the set_unexpected() should call myunexpected() and throw an int exception for the handler is there.Code:#include <iostream> #include <exception> void myunexpected () { std::cerr << "unexpected called\n"; throw 0; / } void myfunction () throw (int) { throw 'x'; } int main (void) { std::set_unexpected (myunexpected); try { myfunction(); } catch (int) { std::cerr << "caught int\n"; } return 0; }
I put debugger, but myunexpected() was not called.
Is something wrong with code implementation or it is run time behavior of set_unexpected() function?
If it is so, then what's the use of set_unexpected() ?
Thanks