C++ catch(std::exception & e ) vs. catch(…)

后端 未结 4 1891
傲寒
傲寒 2020-12-11 03:58

I know the difference in handling of both of these catches, but what does it take for the ellipse to catch something the std::exception catch wouldn\'t catch?

For ex

4条回答
  •  醉话见心
    2020-12-11 04:33

    catch(const std::exception& e)
    

    Will catch std exceptions only.

    catch(...)
    

    Will catch everything there after.

    You can handle integers and other types (http://www.cplusplus.com/doc/tutorial/exceptions/)

    For example:

    catch(int e)
    

提交回复
热议问题