c/c++ Exceptions
来源:互联网 发布:网络虚拟家庭 编辑:程序博客网 时间:2024/06/13 22:52
Exceptions provide a way to react to exceptional circumstances (like runtime errors) in programs by transferring control to special functions called handlers.
To catch exceptions, a portion of code is placed 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.
To catch exceptions, a portion of code is placed 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.
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:
123456789101112131415
// exceptions#include <iostream>using namespace std;int main () { try { throw 20; } catch (int e) { cout << "An exception occurred. Exception Nr. " << e << '\n'; } return 0;}
An exception occurred. Exception Nr. 20
0 0
- c/c++ Exceptions
- C++--异常(Exceptions)
- IEEE floating-point exceptions in C
- Handling Uncaught and Unexpected Exceptions (C++)
- Ry’s Objective-C Tutorial---Exceptions & Errors
- Exceptions and error handling http://yosefk.com/c++fqa/exceptions.html#fqa-17.2
- obj-c中-fobjc-arc-exceptions的解释
- 数据结构与算法(C++)之零——异常类(Exceptions)
- C#: how do I list all System defined Exceptions and pick up what I need
- POI 操作Excel 异常org.apache.poi.openxml4j.exceptions.invalidformatexception: package should contain a c
- ios cannot use "@throw" with objective-c exceptions disabled 问题解决方案
- requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581
- Exceptions
- Exceptions
- [翻译] Effective C++, 3rd Edition, Item 8: 防止因为 exceptions(异常)而离开 destructors(析构函数)
- c
- c
- c
- device_register()和platform_device_register()的区别
- VC、MFC中设置控件的背景色、标题、字体颜色、字体要注意的地方
- servletconfig和ServletContext的用法和区别
- oracle部分维护操作
- paip.杀不死进程的原因--僵尸进程的解决.txt
- c/c++ Exceptions
- Spice架构图解
- 第十二章
- DAY03——VIM常用命令学习笔记(二)
- 编译原理--计算器Flex+Bison实现
- 软件工程师 Book
- JQuery Uploadify 基于JSP的无刷新上传实例
- 黑马程序员-多线程间通信
- 解读11g自动性能统计_相关概念