天天看点

程序异常处理

异常是程序运行时出现的不正常,比如内存耗尽或输入错误。

异常机制提供程序中错误检测与错误处理部分的通信。包括:

throw表达式:

if(expression)

throw runtime_error("error");

do otherthing

try块

try

{

program

}

catch(expression)

handle-statements;

继续阅读