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
}

猜你喜欢

转载自www.cnblogs.com/MakeView660/p/9070724.html