gpt4 book ai didi

c++ - 如何将类中的静态名称引入作用域?

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:25:42 25 4
gpt4 key购买 nike

例如

struct A
{
static void foo();
static void foo(int);
static void foo(double, char);
...
};

在一个范围内

namespace nm
{
using A::foo; // not right
}

如何将类中的静态名称引入作用域?

最佳答案

你不能。

n3376 7.3.3/8

A using-declaration for a class member shall be a member-declaration.

struct X {
int i;
static int s;
};
void f() {
using X::i; // error: X::i is a class member
// and this is not a member declaration.
using X::s; // error: X::s is a class member
//and this is not a member declaration.

}

n3376 7.3.3/3

In a using-declaration used as a member-declaration, the nested-name-specifier shall name a base class of the class being defined.

关于c++ - 如何将类中的静态名称引入作用域?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19627470/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com