#include "iostream"
#include "conio.h"
#include "exception"
#include "cstdlib"
using namespace std;
void myunexpected()
{
cerr << "unexpected called\n";
throw 0; // throws int (in exception-specification)
}
void myfunction() throw (int)
{
throw 'x'; // throws char (not in exception-specification)
}
int main (void)
{
set_unexpected (myunexpected);
try
{
myfunction();
}
catch (int) { cerr << "caught int\n"; }
catch (...) { cerr << "caught other exception (non-compliant compiler?)\n"; }
getch();
return 0;
}
出力を呼び出すことができません: は他の例外をキャッチ例外処理 - set_unexpected()(のVisual Studio 2008上で実行される)
しかし、私は期待していた(非準拠のコンパイラ?)出力は次のようにします
予想外呼ば
はint型
をキャッチ注:私は、Visual Studio上で、このプログラムを実行し、2008年
ありがとう - ):D ;-) – Jatin