Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • Could you please give a reference to the standard?
    – Evg
    Commented Feb 7, 2022 at 13:57
  • 3
    I wouldn't call this a peculiar language quirk. Imagine if A::i were a function being defined out of line, rather than a static data member. You would expect that, inside the body of the function, x would refer to A::x. It's just that when the same thing happens in a static data member definition, it's a little bit surprising because we're not used to it.
    – Brian Bi
    Commented Feb 7, 2022 at 19:19
  • 1
    @Evg eel.is/c++draft/basic.scope.class#1
    – Brian Bi
    Commented Feb 7, 2022 at 19:20
  • Probably best to use the scope operator to avoid an innocent-looking addition of a variable to A breaking the code.
    – user904963
    Commented Feb 16, 2022 at 16:41