home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!snorkelwacker.mit.edu!bloom-beacon!eru.mt.luth.se!hagbard!loglule!jbn
- From: jbn@lulea.trab.se (Johan Bengtsson)
- Newsgroups: comp.lang.c++
- Subject: Re: Inherited nested classes?
- Message-ID: <4902@holden.lulea.trab.se>
- Date: 30 Aug 92 11:35:00 GMT
- References: <1992Aug29.160423.16617@genghis.borland.com>
- Organization: Telia Research AB, Aurorum 6, 951 75 Lulea, Sweden
- Lines: 32
- X-Newsreader: Tin 1.1 PL4
-
- 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?
-
- --
- --------------------------------------------------------------------------
- | Johan Bengtsson, Telia Research AB, Aurorum 6, S-951 75 Lulea, Sweden |
- | jbn@lulea.trab.se; Voice:(+46)92075471; Fax:(+46)92075490 |
- --------------------------------------------------------------------------
-