home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!spool.mu.edu!yale.edu!jvnc.net!nuscc!arthur
- From: arthur@@solomon.technet.sg (Arthur Sombrito)
- Subject: elaborated type-spec scope?
- Message-ID: <1992Sep16.021041.17845@nuscc.nus.sg>
- Sender: usenet@nuscc.nus.sg
- Organization: National University of Singapore
- X-Newsreader: TIN [version 1.1 PL6]
- Date: Wed, 16 Sep 1992 02:10:41 GMT
- Lines: 40
-
-
- I'd like to ask some questions regarding C++ v3.0 rules on
- elaborated type specifiers which are not discussed (as far
- as I could tell) in the ARM.
-
- If an elaborated-type-specifier introduces a new class name, at
- what scope would the new name be added? Is it the current scope
- or the file scope? For example:
-
- class C
- {
- struct T; // ok - C::T
- struct S *sP; // Is S created as C::S or ::S?
- };
- S *sP; // undefined symbol "S" error?
-
- ARM 9.1 states "A class declaration introduces the class name
- into the scope where it is declared..." and
- "An elaborated-type-specifier ... differs from a class
- declaration in that if a class of the elaborated name is in scope
- the elaborated name will refer to it."
-
- If I understood it correctly, "S" should have been created in
- class scope of "C". The problem is it is not what comes out
- when I tried testing it on cfront 2.1, g++ and BC++. All of them
- create the name at file scope.
-
- Assuming that it is created at the current scope, then the following
- would no longer be valid:
-
- :
- :
- void f(class C *cP) // first instantiation of "C"
- {...}
- :
- :
-
- since class C would be created at the local scope of the function.
-
- Thanks for any reply.
-