析构函数参数 [英] Destructor parameters

查看:106
本文介绍了析构函数参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

文章析构函数是否可重载?讨论了重载析构函数.

The article Are destructors overloadable? talks about overloading the destructor.

这提出了一个问题:析构函数可以有参数吗?

This raised a question: Can a destructor have parameters?

我从没使用过或看过带有参数的析构函数.我无法提供一个将参数用于析构函数的理由的示例.

I've never used or seen a destructor with parameters. I could not come up with an example of a reason to use parameters to the destructor.

推荐答案

C ++ 0x草案n3290的第12.4节中有关于析构函数的说法:

Section §12.4 of C++0x draft n3290 has this to say about destructors:

析构函数

使用可选的函数说明符(7.1.2),后跟〜,后跟析构函数的类名,后跟空参数列表的特殊声明符语法用于在类定义中声明析构函数

A special declarator syntax using an optional function-specifier (7.1.2) followed by ˜ followed by the destructor’s class name followed by an empty parameter list is used to declare the destructor in a class definition.

(添加了重点)

因此,析构函数不使用参数. (2003年标准的措辞与上述段落完全相同.)

So no, destructors do not take parameters. (The 2003 standard has the exact wording of the above paragraph.)

这篇关于析构函数参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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