抛出c++语法中的异常
Throwing exceptions in c++ syntax
对于抛出异常,我知道您可以声明/定义函数并暗示它抛出异常
。
void foo(void) throw(const char *) {};
什么时候做这件事比较合适?如果我们要用这种方式声明/定义它,我们是同时使用原型和定义还是只使用定义?还有一件事,如果我们包含了其他东西,构造函数的语法是什么?
。
class bar
{
bar() , a(a) would the throw go here, and would it also in the definition if written elsewhere ?
}
谢谢:-)
不要这样做,它在c++ 11中被弃用有一个很好的理由:它不做人们认为它做的事情。
更新:更多关于这个主题的信息在这里http://www.boost.org/development/requirements.html#Exception-specification
另一个更新:正如@Steve Fallows指出的,这里是关于这个主题的另一个很好的参考:http://www.gotw.ca/publications/mill22.htm
相关文章:
- 1d 智能指针不适用于语法 (*)++
- 处理多个异常集合的C++方法
- 助记符和指向成员语法的指针
- 有人能分解一下这个c++模板的语法吗
- C++避免重复声明的语法是什么
- 我在c++代码中生成了一个运行时#3异常
- QMetaObject invokeMethod的基于函数指针的语法
- 关于异常继承中的语法的问题
- C++异常类扩展语法
- C++ 实例化派生类的语法异常
- C++异常语法
- 此C 异常语法有什么问题(std :: runtime_error)
- 捕获模板类内部定义的异常的语法
- 异常处理语法问题简单
- 使用Boost Spirit解析语法的未处理异常
- c++中异常的规则和语法
- 抛出c++语法中的异常
- C2061:语法错误:标识符'string' - 行为异常
- 在 catch 块异常中无意义地使用引用传递语法
- 这个语法是什么意思?运算符重载和抛出异常