home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 13006 < prev    next >
Encoding:
Internet Message Format  |  1992-08-29  |  3.4 KB

  1. Path: sparky!uunet!mcsun!sunic!hagbard!loglule!jbn
  2. From: jbn@lulea.trab.se (Johan Bengtsson)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Inherited nested classes?
  5. Message-ID: <4900@holden.lulea.trab.se>
  6. Date: 28 Aug 92 11:57:12 GMT
  7. References: <GIROD.92Aug25095844@node_262d6.tele.nokia.fi>
  8. Organization: Telia Research AB, Aurorum 6, 951 75 Lulea, Sweden
  9. Lines: 69
  10. X-Newsreader: Tin 1.1 PL4
  11.  
  12. girod@tele.nokia.fi (Marc Girod) writes:
  13. : In article <4862@holden.lulea.trab.se> jbn@lulea.trab.se (Johan Bengtsson) writes:
  14. : >    jane@mullian.ee.mu.OZ.AU (jane lynette cosham) writes:
  15. : >    : 
  16. : >    : The problem is that MSC 7.0 inherits nested classes and BC 3.0
  17. : >    : doesn't.  MSC also takes note of access modifiers for nested classes.
  18. : > [...]
  19. : > 
  20. : >    Good!  MSC conforms to the base document for the C++ standard,
  21. : >    the Annotated Reference Manual (it's described on page 48).
  22. : Unfortunately, we don't read the same things from the same place... To
  23. : me, ARM p 48 doesn't deal with nested classes (or so marginally that
  24. : it is not relevant here!
  25.  
  26. On reading p48 again, I must admit that you are right.  p48 does not
  27. say what I thought it did (but it should).
  28.  
  29. : It deals with "names", defined at the bottom
  30. : of p 47 as "a form of primary-expression that can appear after. and
  31. : ->"
  32.  
  33. A strange definition of "name" don't you think?  Should be "member-name",
  34. if types are really not "names".  Fine.
  35.  
  36. : To me, the section 9.7 on "Nested Class Declarations" doesn't either
  37. : bring any light onto the issue, apart for the not-so-clear: "The name
  38. : of a nested class is local to its enclosing class", the important word
  39. : being "local". We are thus back to the section 3.2 on "Scopes", p 15,
  40. : which states about Local scope: "A name declared in a block is local
  41. : to that block and can be used only in it and..."; and about Class
  42. : scope: "The name of a class member is local to its class and...". A
  43. : nested class is not a member, so:
  44. : >    : Under BC neither class exists for B, and it is possible to declare a
  45. : >    : variable of type A::nested_a2 anywhere.
  46. : >    : 
  47. : >    : It is my understanding that Borland's implementation is the norm.
  48. : ..was the correct interpretation.
  49.  
  50. ... contradicting ARM p216 (scope rule summary):
  51.  
  52. "The scope rules for C++ [...] apply uniformly for all names (including
  53.  typedef-names and class names), wherever the grammar allows such names
  54.  in the context discussed by a particular rule."
  55.  
  56. Does sound reasonable, no?  I should have tested this with my compilers
  57. first though.  Your view seems to win 2-1 (Sun C++ 2.1 & g++ 1.40.3 vs
  58. ObjectStore C++ 2.1).
  59.  
  60. The differences between "member" and "nested" seem so unnecessary to me.
  61. Why, oh why?
  62.  
  63. : > jane@mullian.ee.mu.OZ.AU (jane lynette cosham) writes:
  64. : > [...] however it causes hassles if the same name cannot be used in
  65. : > more than one level of the class structure.
  66.  
  67. But it can (should).  A nested type name used in a derived class hides
  68. the same nested type in a base class, just like all other names.
  69. In that case, you need to qualify, Base::NestedType, if that is
  70. what you mean.  If this is really a good idea is another issue.
  71.  
  72. -- 
  73. --------------------------------------------------------------------------
  74. | Johan Bengtsson, Telia Research AB, Aurorum 6, S-951 75 Lulea, Sweden  |
  75. | jbn@lulea.trab.se; Voice:(+46)92075471; Fax:(+46)92075490              |
  76. --------------------------------------------------------------------------
  77.