home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13364 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  2.2 KB

  1. Path: sparky!uunet!usc!rpi!bu.edu!Shiva.COM!world!pkturner
  2. From: pkturner@world.std.com (Prescott K Turner)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Inherited nested classes?
  5. Message-ID: <Bu7qAM.5H@world.std.com>
  6. Date: 7 Sep 92 14:44:46 GMT
  7. References: <1992Aug29.160423.16617@genghis.borland.com> <4902@holden.lulea.trab.se> <78983@ut-emx.uucp>
  8. Organization: The World Public Access UNIX, Brookline, MA
  9. Lines: 38
  10.  
  11. In article <4902@holden.lulea.trab.se> jbn@lulea.trab.se (Johan Bengtsson) writes:
  12. > Can struct B use its own name?  After all it is a private name to which
  13. > it has no access (access control applies uniformly to all names,
  14. > including nested types)...
  15.  
  16. pete@genghis.borland.com (Pete Becker) writes: 
  17. > that's clearly a flaw in the wording, and not the intention of the language.
  18.  
  19. jamshid@emx.utexas.edu (Jamshid Afshar) writes (also in response to Bengtsson):
  20. > C'mon, let's save the pedantry for the ANSI C++ draft :-).
  21.  
  22. The point is deeper than pedantry.  Is the flaw a small omission in the
  23. wording, or is the rule "Member functions of a nested class have no special
  24. access to members of an enclosing class" a flaw in itself?
  25.  
  26. A nested class and all of its member functions must be declared within
  27. the body of the enclosing class, so this rule is not needed to enforce
  28. encapsulation.  A nested class is just as much a part of the class
  29. definition as a member function body, and IMO should have the same access
  30. privileges.
  31.  
  32. > in those situations where the inner class needs to "know" the
  33. > internals of its enclosing class, make it a friend.
  34.  
  35. In this way the current rule provides more control by allowing the programmer
  36. to choose which nested classes are friends and have access.  But consider
  37. the fact that ALL member function bodies had access to their class
  38. for 6 years before this became an issue for nested classes, and there
  39. are no requests for a capability to designate certain member functions
  40. not to have access.  This kind of control is just as worthless for nested
  41. classes.
  42.  
  43. It's the rule which is wrong; Johan Bengtsson has pointed out the rule's
  44. most absurd consequence.
  45. --
  46. Prescott K. Turner, Jr.
  47. 13 Burning Tree Rd., Natick, Massachusetts USA
  48. Internet: pkturner@world.std.com
  49.