- 6
- 0
- 约8.87千字
- 约 35页
- 2015-08-14 发布于广东
- 举报
哈尔滨工业大学计算机系代亚非 第4章 异常 4.1 异常的概念 4.2 异常的分类 4.3 捕获异常 4.4 声明异常 4.5 抛出异常 4.6 创造自己的异常 4.7 总结 4.1 异常的概念 什么是异常? 异常实际上是程序中错误导致中断了正常的指令流的一种事件. 没有处理错误的程序: read-file { openTheFile; determine its size; allocate that much memory; closeTheFile; } 4.1 异常的概念 以常规方法处理错误 openFiles; if (theFilesOpen) { determine the lenth of the file; if (gotTheFileLength){ allocate that much memory; if (gotEnoughMemory) { read the file into memory; if (readFailed) errorCode=-1; else errorCode=-2; }else errorCode=-3; }else errorCode=-4 ; }else e
原创力文档

文档评论(0)