程序异常处理

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

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

throw表达式:

if(expression)
throw runtime_error("error");
do otherthing

try块

try
{
program
}
catch(expression)
{
handle
-statements;
}

由标准库定义的一组异常类

posted @ 2011-06-29 20:47  hailong  阅读(314)  评论(0编辑  收藏  举报