用set_terminate设置自己的terminate处理函数

#include <iostream>
using namespace std;

void termin_func()
{
 cout << "自己处理未catch到的异常,可以在这里log出异常状况!!" << endl;

 system("pause");

 exit(0);
}

int _tmain(int argc, _TCHAR* argv[])
{
 /*Sleeper s;
 Watcher w;

 s.SleepFiveSecCallMe(w);
 w.RestFiveSec();*/

 set_terminate(termin_func);

 throw "故意抛出的异常!";

 system("pause");


 return 0;
}

原文地址:https://www.cnblogs.com/youyou/p/279971.html