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++(翁恺浙大公开课) 笔记0
- static在c\c++中的作用(翁恺c++公开课[28-29]学习笔记)
- c++对象初始化(翁恺c++公开课[10])
- c++构造函数的初始化列表(翁恺c++公开课[13])
- c++继承:公有、私有、保护
- c++子类父类关系(翁恺c++公开课[15-16]学习笔记)
- c++拷贝构造函数(翁恺c++公开课[26-27]学习笔记)
- c++多态性及多态的内部实现(翁恺c++公开课[23-24])
- c++中的运算符重载operator1(翁恺c++公开课[30]学习笔记)
- c++中的运算符重载operator2(翁恺c++公开课[31-33]学习笔记)
- c++模板(翁恺c++公开课[34-35]学习笔记)
- 最好不要在头文件中写函数定义