2020
09-28
09-28
C++异常重抛出实例分析
如果我们编写了一个函数,函数内部可能会出现异常,但是我们不想在这个函数内处理,而是想要通知调用者,那么C++允许它重抛出这个异常。语法如下:try{//Executesomecode}catch(Exception&e){//Peformsomeoperationsbeforeexitsthrow;}语句throw重新抛出了异常。看一个实际的例子:#include<iostream>#include<stdexcept>usingnamespacestd;intf(){try{throwruntime_error("Exceptioninf");}...
继续阅读 >