异常处理
来源:互联网 发布:lte mrr弱覆盖优化 编辑:程序博客网 时间:2024/04/30 13:38
**#include <iostream>#include <fstream>#include <cstring>#include <strstream>using namespace std;int main(){ void f1(); try{f1();} catch(double){cout <<"OK0!"<<endl;} cout<<"end0"<<endl; return 0;}void f1(){ void f2(); try {f2();} catch(char) {cout<<"OK1!"<<endl;} cout<<"endl"<<endl;}void f2(){void f3(); try{f3();} catch(int) {cout<<"OK2!"<<endl;} cout<<"end2"<<endl;}void f3(){double a=0;try{throw a;} catch(float) {cout<<"OK3!"<<endl;} cout<<"end3"<<endl;}**
try-catch 语句可以与throw出现在同一个函数中,也可以不在同一个函数中。当throw跑出异常信息后,首先在本函数中寻找与之匹配的catch,如果在本函数中无try-catch结构或则找不到与之匹配的catch,就转到其上一层去处理,如果上一层也无try-catch结构或找不到与之匹配的catch,则在转到更上一层的try-catch结构去处理,也就是说转到离开出现异常最近的try-catch结构去处理。
0 0
- 异常处理+异常+处理异常+自定义异常
- 异常处理
- 异常处理
- 异常处理
- 异常处理
- 异常处理
- 异常处理
- 异常处理
- 异常处理
- 异常处理
- 异常处理
- 异常处理
- 异常处理
- 异常处理
- 异常处理
- 异常处理
- 异常处理
- 异常处理
- 博弈问题
- 个人常用JavaScript及React常用优化总结
- 安卓输入框,只输入中文,屏蔽中英文标点和表情
- 数字图像梯形畸变校正
- L1-011. A-B Java
- 异常处理
- http各个状态返回值
- Apache Ambari 02
- 互斥锁与条件变量
- 局部内部类
- 排序算法--冒泡排序
- Ubuntu 14.04 caffe的Python环境配置
- android 网络编程
- Stereo Matching文献笔记之(九):经典算法Semi-Global Matching(SGM)之神奇的HMI代价计算~