The standard. See ?.3.6/1, point 2: "A name N used in a class
S shall refer to the same declaration in its context and when
re-evaluated in the completed scope of S." In the context
above, the name i refers to the enum at namespace scope. In the
complete scope of the class, it refers to the enum defined later
in the class.
Given that the example he's quoting is taken precisely from this
paragraph, and is given in order to demonstrate this point, it's
rather hard to understand what he's questioning, though.
Now who's complaining about uncompilable code? "reutnr", of
In the example that he's misquoting, this line is followed by
char c ;
So we end up in a variant of the above. Except that in this
case, the name in question ("c") is in a function body, and
the evaluation of function bodies is always in the complete
scope of the class. In the standard, there is a comment on this
line saying that "c", here is "X::c" (which means that the
function is guaranteed to return 1, and not sizeof(int)).
The real problem here seems to be that the original poster
doesn't know how to copy/paste:-).
Seriously, of course, if he'd have copied accurately (the
publicly available version of the standard is, or at least was,
restricted, so that you couldn't copy/paste from it), including
the comments, you'd have seen what was up immediately. But I'll
admit that, seeing the original text, I don't understand what he
doesn't understand about it. There are many places where the
standard is less than clear, but this really isn't one of them.
James Kanze (GABI Software) email: XXXX@XXXXX.COM
Conseils en informatique orient objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sard, 78210 St.-Cyr-l'ole, France, +33 (0)1 30 23 00 34