【发布时间】:2019-04-01 21:35:00
【问题描述】:
我知道在 C++ 中,您可以使用以下方法捕获任何数据类型的异常:
try {
// throw exception here
} catch (...) {
// handle exception here
}
但我想捕获任何 C++ 标准异常,例如 std::logic_error、std::out_of_range,而不是其他数据类型,例如 string 或 int。如何仅捕获 C++ 标准异常?我想在传入的 C++ 标准异常对象上调用exp.what(),而使用上面的代码是不可能的。
【问题讨论】:
-
hint.