home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 13106 < prev    next >
Encoding:
Internet Message Format  |  1992-08-31  |  1.7 KB

  1. Path: sparky!uunet!olivea!decwrl!borland.com!pete
  2. From: pete@genghis.borland.com (Pete Becker)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Inherited nested classes?
  5. Message-ID: <1992Aug31.180412.29730@genghis.borland.com>
  6. Date: 31 Aug 92 18:04:12 GMT
  7. References: <1992Aug29.160423.16617@genghis.borland.com> <4902@holden.lulea.trab.se>
  8. Sender: news@borland.com (News Admin)
  9. Organization: Borland International
  10. Lines: 32
  11. Originator: pete@genghis.borland.com
  12.  
  13. In article <4902@holden.lulea.trab.se> jbn@lulea.trab.se (Johan Bengtsson) writes:
  14. >pete@genghis.borland.com (Pete Becker) writes:
  15. >: In article <1992Aug28.164813.51739@evolving.com> jcm@evolving.com (Jack Morrison) writes:
  16. >: >
  17. >: >    class C {
  18. >: >    private:
  19. >: >        struct A { int x; };
  20. >: >        struct B { A a1; };
  21. >: >        A a2;
  22. >: >    };
  23. >: >
  24. >: >The AIX 3.2 xlC compiler complains about the struct B declaration, saying
  25. >: >it can't access private type C::A. I guess I understand this, since B is
  26. >: >basically a (nested) class. [...]  Making A *public* works, but I 
  27. >: >didn't really want to bother anyone outside the class with the struct type.
  28. >: 
  29. >: [...]
  30. >: The name of a private member "can be used only by member
  31. >: functions and friends of the class in which it is declared."
  32. >: [...] Since struct B is neither a member function
  33. >: nor a friend of class C, it cannot use the name of struct A.
  34. >
  35. >Can struct B use its own name?  After all it is a private name to which
  36. >it has no access (access control applies uniformly to all names,
  37. >including nested types)...
  38. >
  39. >Are private nested types useful at all, given the current language definition?
  40. >
  41.  
  42.     I'm not aware of any compiler that enforces the privacy of the name of
  43. B within B.  Agreed, it's a problem in the current wording...
  44.     -- Pete
  45.