Class static variable initialization order

That’s correct according to the lookup rules. [basic.lookup.unqual]/13 says:

A name used in the definition of a static data member of class X
(after the qualified-id of the static member) is looked up as if the
name was used in a member function of X. [ Note: [class.static.data]
further describes the restrictions on the use of names in the
definition of a static data member.  — end note ]

Since the unqualified a is looked up as if you are inside a member function, it must find the member A::a first. The initialization order of A::a and A::b doesn’t affect the lookup, though it affects how well defined the result is.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)