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