首页 > 编程语言 > 详细

c++中的Exceptions异常处理(翁恺c++公开课[36])

时间:2020-02-13 09:32:40      阅读:79      评论:0      收藏:0      [点我收藏+]

Exceptions用于处理Run-time Error;

//文件读取的异常捕获伪代码
try{
    open the file;
    determine its size;
    allocate that much memory;
    read the file into memory;
    close the file;
}catch(fileOpenFailed){
    doSomething;
}catch(sizeDeterMinationFailed){
    doSomething;
}catch(memoryAllocationFailed){
    doSomething;
}catch(readFailed){
    doSomething;
}catch(fileCloseFailed){
    doSomething;   
}

 异常,让函数发现有自己无法处理的错误时抛出一个异常

c++中的Exceptions异常处理(翁恺c++公开课[36])

原文:https://www.cnblogs.com/go-ahead-wsg/p/12150226.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!