home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13723 < prev    next >
Encoding:
Text File  |  1992-09-15  |  1.6 KB  |  52 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!spool.mu.edu!yale.edu!jvnc.net!nuscc!arthur
  3. From: arthur@@solomon.technet.sg (Arthur Sombrito)
  4. Subject: elaborated type-spec scope?
  5. Message-ID: <1992Sep16.021041.17845@nuscc.nus.sg>
  6. Sender: usenet@nuscc.nus.sg
  7. Organization: National University of Singapore
  8. X-Newsreader: TIN [version 1.1 PL6]
  9. Date: Wed, 16 Sep 1992 02:10:41 GMT
  10. Lines: 40
  11.  
  12.  
  13. I'd like to ask some questions regarding C++ v3.0 rules on
  14. elaborated type specifiers which are not discussed (as far
  15. as I could tell) in the ARM.
  16.  
  17. If an elaborated-type-specifier introduces a new class name, at 
  18. what scope would the new name be added? Is it the current scope
  19. or the file scope?  For example:
  20.  
  21.   class C
  22.   {
  23.     struct T;        // ok - C::T
  24.     struct S *sP;    // Is S created as C::S or ::S?
  25.   };
  26.   S *sP;        // undefined symbol "S" error?
  27.  
  28. ARM 9.1 states "A class declaration introduces the class name 
  29. into the scope where it is declared..." and 
  30. "An elaborated-type-specifier ... differs from a class 
  31. declaration in that if a class of the elaborated name is in scope
  32. the elaborated name will refer to it."
  33.  
  34. If I understood it correctly, "S" should have been created in
  35. class scope of "C".  The problem is it is not what comes out
  36. when I tried testing it on cfront 2.1, g++ and BC++.  All of them
  37. create the name at file scope.
  38.  
  39. Assuming that it is created at the current scope, then the following
  40. would no longer be valid:
  41.  
  42.        :
  43.        :
  44.    void f(class C *cP) // first instantiation of "C"
  45.    {...} 
  46.        :
  47.        :
  48.  
  49. since class C would be created at the local scope of the function.
  50.  
  51. Thanks for any reply.
  52.