私はcplusplus.comから取得した次のコードを持っています:
// set_terminate example
#include <iostream>
#include <exception>
#include <cstdlib>
using namespace std;
void myterminate () {
cout << "terminate handler called\n";
abort(); // forces abnormal termination
}
int main (void) {
set_terminate (myterminate);
throw 0; // unhandled exception: calls terminate handler
return 0;
}
コードには未処理の例外があるため、終了ハンドラーとして設定され、デフォルトの終了ハンドラーをオーバーライドすることになっているmyterminate()関数を呼び出す必要があります。
プログラムはクラッシュしていますが、myterminate()を呼び出していません。Visual C ++ 2008ExpressEditionを使用しています。
コードの問題は何ですか?