[class.static.general] (original) (raw)
11 Classes [class]
11.4 Class members [class.mem]
11.4.9 Static members [class.static]
11.4.9.1 General [class.static.general]
A static member s of class X may be referred to using the qualified-id expression X::s; it is not necessary to use the class member access syntax ([expr.ref]) to refer to a static member.
A static member may be referred to using the class member access syntax, in which case the object expression is evaluated.
[Example 1: struct process { static void reschedule();}; process& g();void f() { process::reschedule(); g().reschedule(); } — _end example_]
A static member may be referred to directly in the scope of its class or in the scope of a class derived ([class.derived]) from its class; in this case, the static member is referred to as if a qualified-id expression was used, with thenested-name-specifier of the qualified-id naming the class scope from which the static member is referenced.
[Example 2: int g();struct X { static int g();};struct Y : X { static int i;};int Y::i = g(); — _end example_]
Static members obey the usual class member access rules ([class.access]).
When used in the declaration of a class member, the static specifier shall only be used in the member declarations that appear within the member-specification of the class definition.
[Note 1:
It cannot be specified in member declarations that appear in namespace scope.
— _end note_]