c++ exception
如果违反了异常规范,会出现什么样的行为?
看看这个小程序:
#include <iostream>
using namespace std;
class e{};
void foo() throw ()
{
throw 1;
}
void une()
{
cout << "unexpected...";
}
int main()
{
set_unexpected(une);
try{
foo();
}
catch(...)
{
cout << "catch it!";
}
}
在 .net2003下 结果是显示catch it!
在dev-cpp下 会显示unexpected..., 然后出错退出。
大家有什么样的理解?谢谢。