#include <iostream> #include <string> #include <exception> using namespace std; class Test { public: Test() { cout << "Test" << endl; } ~Test() { cout << "~Test" << endl; } }; void my_terminate() { cout << "void my_terminate()" << endl; //确保所有全局对象和静态局部对象全部正常启动 exit(1); //异常中止程序,不会调用对象的析构函数 //abort(); } int main() { set_terminate(my_terminate); static Test t; throw 1; return 0; }
Test void my_terminate() ~Test
原文:https://www.cnblogs.com/chengeputongren/p/12311002.html