home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!decwrl!borland.com!pete
- From: pete@genghis.borland.com (Pete Becker)
- Newsgroups: comp.lang.c++
- Subject: Re: Inherited nested classes?
- Message-ID: <1992Aug31.180412.29730@genghis.borland.com>
- Date: 31 Aug 92 18:04:12 GMT
- References: <1992Aug29.160423.16617@genghis.borland.com> <4902@holden.lulea.trab.se>
- Sender: news@borland.com (News Admin)
- Organization: Borland International
- Lines: 32
- Originator: pete@genghis.borland.com
-
- In article <4902@holden.lulea.trab.se> jbn@lulea.trab.se (Johan Bengtsson) writes:
- >pete@genghis.borland.com (Pete Becker) writes:
- >: In article <1992Aug28.164813.51739@evolving.com> jcm@evolving.com (Jack Morrison) writes:
- >: >
- >: > class C {
- >: > private:
- >: > struct A { int x; };
- >: > struct B { A a1; };
- >: > A a2;
- >: > };
- >: >
- >: >The AIX 3.2 xlC compiler complains about the struct B declaration, saying
- >: >it can't access private type C::A. I guess I understand this, since B is
- >: >basically a (nested) class. [...] Making A *public* works, but I
- >: >didn't really want to bother anyone outside the class with the struct type.
- >:
- >: [...]
- >: The name of a private member "can be used only by member
- >: functions and friends of the class in which it is declared."
- >: [...] Since struct B is neither a member function
- >: nor a friend of class C, it cannot use the name of struct A.
- >
- >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)...
- >
- >Are private nested types useful at all, given the current language definition?
- >
-
- I'm not aware of any compiler that enforces the privacy of the name of
- B within B. Agreed, it's a problem in the current wording...
- -- Pete
-