set_unexpected called because the function hasn't permission to throw exceptions. After, terminate function is launched.
PHP Code:
#include <iostream>
#include <string>
#include <stdexcept>
using namespace std;
////////////////////////// samaple class
class DivideForZeroException : public runtime_error {
public:
DivideForZeroException()
: runtime_error("Impossibile dividere per 0\n")
{}
};
///////////// termiante and unexpected functions
void terminate_function(){
cout << "terminate_function" << endl;
}
void unexpected_function(){
cout << "unexpected_function" << endl;
}
////////////// the function called to throw excpetion
void function() throw(){
try{
throw DivideForZeroException();
}
catch (DivideForZeroException & error){
throw ;
}
}
int main (void){
set_terminate(terminate_function);
set_unexpected(unexpected_function);
::function();
return 0;
}
Comment