i am using a visual studio c++ compiler,& during my study on exception handling,i came across a number of features that can't be supported by visual c++ compiler, like controlling the exceptions that can be thrown out of a function. also i was unable to modify the functioning of terminate() using set_terminate() . is it a specification too for visual c++ to modify terminate()?...& if so,then can anyone explain that why microsoft is cre开发者_开发技巧ating these specifications in its compilers?...:-x
what do you mean you were unable to modify terminate
have you tried something like this ?
// set_terminate example
#include <iostream>
#include <exception>
#include <cstdlib>
using namespace std;
void myterminate () {
cerr << "terminate handler called\n";
abort(); // forces abnormal termination
}
int main (void) {
set_terminate (myterminate);
throw 0; // unhandled exception: calls terminate handler
return 0;
}
Don't try to run from VS. Compile and exec from command line.
精彩评论