各位高手,问一个c++throw()的问题
根据标准解释的,ff()这个函数声明的时候加上throw()就表明这个函数不会抛出任何异常,但是我试了一下下面的代码,还是可以抛出异常的,我在g++ 3.4.2版本下测试的代码。这是为什么呢?
#include <iostream>
using namespace std;
void ff(void)throw();
void ff(void)throw()
{
try{
char a = 3;
throw a;
}
catch(int e)
{
cout << e;
}
catch(...)
{
cout << "default";
}
}
int main()
{
ff();
return 0;
}