`void func()throw(type)'的意义是什么? [英] What is the point of `void func() throw(type)`?

查看:121
本文介绍了`void func()throw(type)'的意义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是一个有效的c ++程序。
在函数declarement中抛出的点是什么? AFAIK它什么都不做,不用于任何东西。

I know this is a valid c++ program. What is the point of the throw in the function declarement? AFAIK it does nothing and isnt used for anything.

#include <exception>
void func() throw(std::exception) { }
int main() { return 0; }


推荐答案

这是一个异常规范,当然是坏主意

That is an exception specification, and it is almost certainly a bad idea.

它说明 func 可能会抛出 std :: exception 和任何其他异常 func emit将导致调用 unexpected()

It states that func may throw a std::exception, and any other exception that func emits will result in a call to unexpected().

这篇关于`void func()throw(type)'的意义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆