c++ - 析构函数参数

标签 c++ parameters destructor

文章Are destructors overloadable?谈论重载析构函数。

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

我从未使用或见过带参数的析构函数。我想不出一个使用析构函数参数的例子。

最佳答案

C++0x 草案 n3290 第 12.4 节对析构函数有这样的说法:

Destructors

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 年标准有上述段落的确切措辞。)

关于c++ - 析构函数参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6245295/

相关文章:

java - 如何将接口(interface)中测试的值传递给 Java 代码?

C++ 类构造函数/析构函数

带有 ARC 的 Objective-C 析构函数

c++ - 如何隐藏 dll 导出类中的成员变量

c++ - 如何获取调用COM服务器方法的用户名?

c++ - 返回 C++ 中的引号

c++ - 如何将 vector<T> 解析为模板函数的函数参数?

kotlin - Kotlin:为什么“未解析的引用”是密封类的子类的构造函数参数

javascript - 将未知数量的参数传递给 js 构造函数

c++ - 从析构函数内部调用 delete 会导致堆栈溢出吗?