home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!cs.utexas.edu!ut-emx!jamshid
- From: jamshid@ut-emx.uucp (Jamshid Afshar)
- Newsgroups: comp.lang.c++
- Subject: Re: Inherited nested classes?
- Summary: just make them friends
- Message-ID: <78983@ut-emx.uucp>
- Date: 2 Sep 92 23:32:13 GMT
- References: <1992Aug29.160423.16617@genghis.borland.com> <4902@holden.lulea.trab.se>
- Reply-To: jamshid@emx.utexas.edu
- Organization: The University of Texas at Austin; Austin, Texas
- Lines: 26
-
- 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)...
-
- C'mon, let's save the pedantry for the ANSI C++ draft :-).
-
- >Are private nested types useful at all, given the current language definition?
-
- Yes -- in those situations where the inner class needs to "know" the
- internals of its enclosing class, make it a friend.
-
- class A {
- enum E { zero, one, two, three }; // a private type of A
- class PrivateBuddy; friend PrivateBuddy;
- class PrivateBuddy {
- E e; // E only accessible to A and friends
- //...
- };
- public:
- //...
- };
- // A::PrivateBuddy and A::E only accessible by A
-
- Jamshid Afshar
- jamshid@emx.utexas.edu
-