class Base
{
public:
virtual const ::std::string& test()
{
return "";
}
};
class Base1
{
public:
virtual const ::std::string& test()
{
return *value_;
}
protected:
::std::string* value_;
};
void testException()
{
try
{
Base1* abc = NULL;
abc->test();
//throw "Out of memory!"; // No catch handler for this exception
}
catch(
)
{
cout << "Integer exception raised." << endl;
}
}
{
public:
virtual const ::std::string& test()
{
return "";
}
};
class Base1
{
public:
virtual const ::std::string& test()
{
return *value_;
}
protected:
::std::string* value_;
};
void testException()
{
try
{
Base1* abc = NULL;
abc->test();
//throw "Out of memory!"; // No catch handler for this exception
}
catch(

{
cout << "Integer exception raised." << endl;
}
}
在【屬性】-》【C/C++】-》【代碼生成】-》【啟用C++異常】有如下4個選項,點擊組合框,顯示:
否
是(/EHsc)
是,但有 SEH 異常(/EHa)
<從父級或項目默認設置繼承>
如果不選擇【是,但有 SEH 異常(/EHa)】選項,try { } catch(...) {} 不起作用。新建項目缺省值是【是(/EHsc)】。就是說在缺省情況下微軟不支持標準C++。