St.Antario
St.Antario

Reputation: 27385

Name used in the static data member definition after unqualified id

From the sec. 3.4.1/13 of N3797:

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.

it is unclear how is looked up a name used in the definition of a static data member of class X after the unqualified-id of the data member. I need a quote from the standard.

Upvotes: 0

Views: 74

Answers (1)

ForEveR
ForEveR

Reputation: 55887

All is writed in 9.4.2. Quote from 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 ]

Upvotes: 1

Related Questions