try { // Execute some code that might throw an exception. } catch( CException* e ) { // Handle the exception here. // "e" contains information about the exception. e->Delete(); }
我这里没有用mfc,CException 显然不成 有 不使用mfc的吗?
try { // Execute some code that might throw an exception. } catch( exception& e ) { // Handle the exception here. // "e" contains information about the exception. cout << "exception catched:" << e.what() << endl; }
{
// Execute some code that might throw an exception.
}
catch( CException* e )
{
// Handle the exception here.
// "e" contains information about the exception.
e->Delete();
}
有 不使用mfc的吗?
{
// Execute some code that might throw an exception.
}
catch( exception& e )
{
// Handle the exception here.
// "e" contains information about the exception.
cout << "exception catched:" << e.what() << endl;
}
{
if (sError != sErrorMsg)
strncpy(sError,sErrorMsg,128);
}
catch(_com_error &e)
{
PrintComErrorString(sError,e);
}
catch(...)
{
strcpy(sError,"未知错误!");
}
{
if(n2==0)
throw "there is an error!"
}
{
if(n2==0)
throw "there is an error!"
else
return n1*1.0/n2;}
void test()
{
float f1;
try
{
f1=mydiv(2,9)
}
catch( CString e)
{
AfxMessageBox(e);
}
catch(...)
{
AfxMessageBox("an uncatch error!");
}
}