这可能是一个微不足道的问题 - 但对我来说并不明显,所以我需要一些确认。假设我在函数中有一个 try-catch 块:
int function some_crap() {
some_type b;
int a = 10;
try {
a = boost::numeric_cast<int>(b);
}
catch(boost::bad_numeric_cast& e) {
std::cout << e.what() << std::endl;
return a;
}
catch(...) {
//-Handle other unknown exceptions
return a;
}
return a;
}
IIRC,我需要将return a
语句放在每个catch
块中,对吗?同样在每个catch
块中,a
都会有 value 10
,对吧?
感谢您的时间和兴趣。--T