catch(…) vs catch(CException *)?
转自:https://stackoverflow.com/questions/7412185/what-is-the-difference-between-catch-vs-catchcexception
try
{
}
catch( const CException & e )
{
// catch all CExceptions
// as far as I know it is ok now to catch CException by reference with modern Microsoft compilers? It was not always the recommended microsoft way
//catch(CException)
will catch only thrown instances of CException
and its subclasses
}
catch( const std::exception & e )
{
// catch standard C++ exception,you can use e.what() to know what exception you caught
}
catch( ... )
{
// catch others
}
希望大家能把自己的所学和他人一起分享,不要去鄙视别人索取时的贪婪,因为最应该被鄙视的是不肯分享时的吝啬。