gpt4 book ai didi

c++ - 在非限定 id 之后的静态数据成员定义中使用的名称

转载 作者:行者123 更新时间:2023-11-28 06:51:11 26 4
gpt4 key购买 nike

从秒。 N3797 的 3.4.1/13:

A name used in the definition of a static data member of class X (9.4.2) (after the qualified-id of the static member) is looked up as if the name was used in a member function of X.

不清楚如何在数据成员的 unqualified-id 之后查找在类 X 的静态数据成员定义中使用的名称。我需要标准的报价。

最佳答案

全部写在9.4.2。引自 n3376 9.4.2/2

In the definition at namespace scope, the name of the static data member shall be qualified by its class name using the :: operator. The initializer expression in the definition of a static data member is in the scope of its class [ Example:

class process 
{
static process* run_chain;
static process* running;
};

process* process::running = get_main();
process* process::run_chain = running;

The static data member run_chain of class process is defined in global scope; the notation process ::run_chain specifies that the member run_chain is a member of class process and in the scope of class process. In the static data member definition, the initializer expression refers to the static data member running of class process. — end example ]

关于c++ - 在非限定 id 之后的静态数据成员定义中使用的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23926678/

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