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: 重新抛出采用一个不带运算对象的throw语句 重新抛出的异常就是当初捕捉到的那个异 常,而不仅仅是异常处理器能访问到的那个 部分 Beijing University of Posts & Telecommunications Beijing [email protected] 重新抛出示例 void h() { try { // 可能抛出Matherr的代码 } catch(Matherr){ if(can_handle_it_completed){ //处理Matherr return; } else{ //完成这里能做的事情 throw; } } } Beijing University of Posts & Telecommunications Beijing [email protected] 14.3.2 捕捉所有异常 对于函数,省略号”…”表示“任何参数”,同 样,catch(…)表示要“捕捉所有异常” void m() { try { // 一些代码 } catch(...) {//处理所有异常 // 清理工作 throw; } } Beijing University of Posts & Telecommunications Beijing [email protected] 14.3.2.1 处理器的顺序 派生异常可能 被多于一个异 常类型的处理 器捕捉,因 此,在写try语 句时处理器的 排列顺序非常 重要 void f() { try{ //... } c...
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