C++编程(C)

C 编程(C)

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (Overflow){/*...*/} catch(Underflow){/*...*/} catch(Zerodivice){/*...*/} //… } 若不使用结组机制,需要列举所有 异常 缺点: 1 忘记列出某个异常 2 当向数学库添加新异常时,每段 试图处理所有数学异常的代码都必 须修改,其结果就是,某个库一旦 发布,就无法再加入任何新异常了 注意: 无论是内部的数学操作,还是基本 的数学库,都没有将算术错误报告 为异常(比如除0,在许多流水线机 器系统结构中都是非同步的操作) Beijing University of Posts & Telecommunications Beijing [email protected] 14.2.1 派生的异常 由于异常的类层次结构,很多情况下,异常 捕捉代码块只针对基类(而不是特定的子类) 异常进行捕捉 捕捉和命名异常的语义等同于函数接受参数 语义 Beijing University of Posts & Telecommunications Beijing [email protected] 派生的异常示例 class matherr{ //... virtual void debug_print() const { ceer << "Math err...
View Full Document

This note was uploaded on 02/10/2014 for the course ECE C++ taught by Professor Xiaoshengtang during the Fall '13 term at BUPT.

Ask a homework question - tutors are online