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

  1. Path: sparky!uunet!snorkelwacker.mit.edu!bloom-beacon!eru.mt.luth.se!hagbard!loglule!jbn
  2. From: jbn@lulea.trab.se (Johan Bengtsson)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Inherited nested classes?
  5. Message-ID: <4902@holden.lulea.trab.se>
  6. Date: 30 Aug 92 11:35:00 GMT
  7. References: <1992Aug29.160423.16617@genghis.borland.com>
  8. Organization: Telia Research AB, Aurorum 6, 951 75 Lulea, Sweden
  9. Lines: 32
  10. X-Newsreader: Tin 1.1 PL4
  11.  
  12. pete@genghis.borland.com (Pete Becker) writes:
  13. : In article <1992Aug28.164813.51739@evolving.com> jcm@evolving.com (Jack Morrison) writes:
  14. : >
  15. : >    class C {
  16. : >    private:
  17. : >        struct A { int x; };
  18. : >        struct B { A a1; };
  19. : >        A a2;
  20. : >    };
  21. : >
  22. : >The AIX 3.2 xlC compiler complains about the struct B declaration, saying
  23. : >it can't access private type C::A. I guess I understand this, since B is
  24. : >basically a (nested) class. [...]  Making A *public* works, but I 
  25. : >didn't really want to bother anyone outside the class with the struct type.
  26. : [...]
  27. : The name of a private member "can be used only by member
  28. : functions and friends of the class in which it is declared."
  29. : [...] Since struct B is neither a member function
  30. : nor a friend of class C, it cannot use the name of struct A.
  31.  
  32. Can struct B use its own name?  After all it is a private name to which
  33. it has no access (access control applies uniformly to all names,
  34. including nested types)...
  35.  
  36. Are private nested types useful at all, given the current language definition?
  37.  
  38. -- 
  39. --------------------------------------------------------------------------
  40. | Johan Bengtsson, Telia Research AB, Aurorum 6, S-951 75 Lulea, Sweden  |
  41. | jbn@lulea.trab.se; Voice:(+46)92075471; Fax:(+46)92075490              |
  42. --------------------------------------------------------------------------
  43.