Topic: enum/class-name reserved words


Author: kdw@dsbc.icl.co.uk (Keith Walker)
Date: Fri, 4 Nov 1994 13:37:46 GMT
Raw View
I am wondering if a knowledgable C++ person could clarify the meaning
of a couple of sentences in the DRAFT C++ Standard which I am having
problems understanding.

The sections about declarations of enumerations and classes contain the
following statements:

 "An enumeration is a distinct type with named constants.  Its name
  becomes an enum-name, that is, a reserved word within its scope."

 "A class is a type.  Its name becomes a class-name, that is, a
  reserved word within its scope."

What is important about the enum-name and class-name being reserved words?
An example which demonstrates it would be great.

I'm also not clear what scope these definitions are referring to.  Is it, for
example, the scope of the actual class; thus rendering the following
illegal:

 struct S {
  int S;  // S reserved word
 };

Or is it intended to be the scope in which the declaration occurs:

 struct S {
  int i;
 };
 int S;   // S reserved word

If its the former then where is the scope of an enumeration defined?  If the
latter then why does the standard go on to explicitly allow this ... i.e
what use is the fact that a class-name is a reserved word?



I have also noticed that Section 2 on lexical conventions doesn't document
the ellipsis "..." token.   Is this an oversight or is it not a single token?
All other possible tokens appear to be documented in section 2 so this is
a surprising ommision.

 Keith Walker

Keith Walker, ICL, Lovelace Rd., Bracknell, Berkshire, United Kingdom RG12 8SN
Email: kdw@oasis.icl.co.uk; Phone: +44 1344 472209 ; Fax: +44 1344 473000