c++异常捕获

会。std::out_of_range 继承自 std::logic_error。所以从 throw (std::logic_error) 可以得知允许抛出。以下引用自 C++11 §15.4/7An exception-specification can include the same type more than once and can include classes that are related by inheritance, even though doing so is redundant.(异常说明中可以包含同一类型一次以上,也可以包含有继承关系的类。尽管前述行为是多余的。)附录:MSVC 在这方面是不标准的。除了 throw() 以外的形式都只解析而不实际使用。见:Exception SpecificationsC++11 已经废弃了 dynamic exception specifications,请使用更省心的 noexcept
■网友
Exception specifications are deprecated in C++11.http://en.wikipedia.org/wiki/C++11#Features_removed_or_deprecated
■网友
不要这样用,C++已经不再支持异常规范。异常本来应该是接口的一部分,但是C++支持的不好,只能暂时放弃。以后还会以某种方式回来的。
■网友
其实我也想了解c++一些异常捕获机制,有时候运行程序时,在半路就遇到异常而终止,一般情况下,我无法定位错误的位置。调试起来非常的烦扰


    推荐阅读