你自己去体会吧:Here is an example of exception-handling code using MFC exception macros. Note that because the code in the following example uses the macros, the exception e is deleted automatically:TRY { // Do something to throw an exception. } CATCH(CException, e) { if (m_bPassExceptionsUp) THROW_LAST(); if (m_bReturnFromThisFunction) return; // Not necessary to delete the exception e. } END_CATCHThe code in the next example uses the C++ exception keywords, so the exception must be explicitly deleted:try { // Do something to throw an exception. } catch(CException* e) { if (m_bPassExceptionsUp) throw; if (m_bThrowDifferentException) { e->Delete(); throw new CMyOtherException; } if (m_bReturnFromThisFunction) { e->Delete(); return; } e->Delete(); }
{
// Do something to throw an exception.
}
CATCH(CException, e)
{
if (m_bPassExceptionsUp)
THROW_LAST(); if (m_bReturnFromThisFunction)
return; // Not necessary to delete the exception e.
}
END_CATCHThe code in the next example uses the C++ exception keywords, so the exception must be explicitly deleted:try
{
// Do something to throw an exception.
}
catch(CException* e)
{
if (m_bPassExceptionsUp)
throw; if (m_bThrowDifferentException)
{
e->Delete();
throw new CMyOtherException;
} if (m_bReturnFromThisFunction)
{
e->Delete();
return;
} e->Delete();
}