C++相談室 part6
■ このスレッドは過去ログ倉庫に格納されています
0285デフォルトの名無しさん
NGNGg++だとchar *を投げても受け取られませんね。
#include <iostream>
#include <cstdlib>
#include <exception>
using namespace std;
void my_terminate()
{
cout << "unexpected error occured!" << endl;
exit(1);
}
void foo(int i) throw (char *)
{
if (i == 0) throw "zero";
cout << "non-zero";
}
int main()
{
set_terminate(my_terminate);
try {
foo(0);
}
catch (char *s) {
cout << "error : " << s <<endl;
}
}
■ このスレッドは過去ログ倉庫に格納されています