c++ 异常exception这部分看了半天, 不明白到底什么意思啊
时间:2011-12-13
来源:互联网
http://www.cplusplus.com/doc/tutorial/exceptions/( E0 @6 ]9 A' u1 c3 H K( A
这代码到底是干嘛的?
这代码到底是干嘛的?
复制内容到剪贴板
using namespace std;
int main ()
{ try { throw 20; }
catch (int e) {
cout << "An exception occurred. Exception Nr. " << e << endl; }
return 0;}
[ 本帖最后由 alleni 于 2011-12-13 06:16 编辑 ] 代码:
#include <iostream>using namespace std;
int main ()
{ try { throw 20; }
catch (int e) {
cout << "An exception occurred. Exception Nr. " << e << endl; }
return 0;}
作者: alleni 发布时间: 2011-12-13
Exceptions provide a way to react to exceptional circumstances (like runtime errors) in our program by transferring control to special functions called handlers./ z4 }% b+ b8 D" P
2 S: g n' A/ @% _ P, q
To catch exceptions we must place a portion of code under exception inspection. This is done by enclosing that portion of code in a try block. When an exceptional circumstance arises within that block, an exception is thrown that transfers the control to the exception handler. If no exception is thrown, the code continues normally and all handlers are ignored.7 b5 P: R% }$ E& b6 x0 v
7 w9 F8 n6 H% m8 N& J. ]An exception is thrown by using the throw keyword from inside the try block. Exception handlers are declared with the keyword catch, which must be placed immediately after the try block:" q( j$ f) J( F+ \1 t3 `1 E
英文你应该比我学得好,我就不多解释了; O$ f4 E' j* b! \6 s1 m
try中掏出异常,然后把控制权转给句柄(handle,应该是这样翻译)执行相应语句
2 S: g n' A/ @% _ P, q
To catch exceptions we must place a portion of code under exception inspection. This is done by enclosing that portion of code in a try block. When an exceptional circumstance arises within that block, an exception is thrown that transfers the control to the exception handler. If no exception is thrown, the code continues normally and all handlers are ignored.7 b5 P: R% }$ E& b6 x0 v
7 w9 F8 n6 H% m8 N& J. ]An exception is thrown by using the throw keyword from inside the try block. Exception handlers are declared with the keyword catch, which must be placed immediately after the try block:" q( j$ f) J( F+ \1 t3 `1 E
英文你应该比我学得好,我就不多解释了; O$ f4 E' j* b! \6 s1 m
try中掏出异常,然后把控制权转给句柄(handle,应该是这样翻译)执行相应语句
作者: 月夜幻影 发布时间: 2011-12-13
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28