gpt4 book ai didi

c++ - A::B::B::B::B...B::f() 对吗?为什么我可以这样做?

转载 作者:行者123 更新时间:2023-12-03 10:04:19 26 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Why is there an injected class name?

(1 个回答)


12 个月前关闭。




我不知道如何解释:

namespace A
{
struct B
{
static void f()
{
}
};
}

int main()
{
A::B::B::B::B::B::B::B::B::B::B::f();
}

为什么我可以这样做:
A::B::B::B::B::B::B::B::B::B::B::f();
我不明白为什么会这样。

最佳答案

这是由于 injected-class-name
B级内部,B指类 B , 如 B::B .
所以A::B::B指类 B .等等。

关于c++ - A::B::B::B::B...B::f() 对吗?为什么我可以这样做?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65358148/

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