home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / cplus / 18280 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  2.0 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!utcsri!relay.cs.toronto.edu!compuserve.com!76336.3114
  2. Newsgroups: comp.lang.c++
  3. From: 76336.3114@CompuServe.COM (Kevin Dean)
  4. Subject: Private base classes
  5. Message-ID: <921221185102_76336.3114_EHJ5-2@CompuServe.COM>
  6. Date: 21 Dec 92 18:55:42 GMT
  7. Lines: 48
  8.  
  9. From John Max Skeller, <1992Dec19.185132.13319@ucc.su.OZ.AU>:
  10.  
  11. >In article <921216205429_76336.3114_EHJ34-2@CompuServe.COM>
  12. >76336.3114@CompuServe.COM (Kevin Dean) writes:
  13. >>
  14. >>I tried to do the following:
  15. >>
  16. >>class A {};
  17. >>class B : private A {};
  18. >>class C1 : public B, public A {};
  19. >>
  20. >>My compiler naturally warned me about A being both a direct and indirect
  21. >>base class of C1 and so refused to compile it.
  22.  
  23. >     It was nice for your compiler to warn you.
  24. >     It was wrong for it to refuse your perfectly valid request.
  25. >     Your compiler is broken.
  26.  
  27. >     Replicated *direct* bases are illegal, if only because there would
  28. >     be no way to disambiguate them.
  29.  
  30. According to a note sent directly to me by Steve Clamage of TauMetric
  31. Corp and, I believe, the C++ language committee, the construct is indeed
  32. ambiguous because access rights are checked only after ambiguities are
  33. resolved; trying to do it the other way around would introduce other
  34. problems.  Given that access priviliges have no bearing on ambiguity
  35. resolution, what I was trying to do is illegal.
  36.  
  37. However, that said, I still think there should be a way to do this, if
  38. only because, once a class is defined and documented, it can't be reliably
  39. changed even if the public and protected interfaces remain the same.
  40.  
  41. >>In other words, I need to have forward
  42. >>knowledge of all classes that are or could be derived from B. 
  43. >>Similarly,I need to know more about B than just its public and
  44. >>protected interfaces; I need to know what its private base classes are
  45. >>before I can reliably use it as a base class.
  46.  
  47. >     Yes, and this is why others believe private *should* mean
  48. >hidden, so you dont have to know about implementation details.
  49.  
  50. >So what do you think of that?
  51.  
  52. It's got my vote. 
  53.  
  54. Kevin Dean
  55.  
  56.  
  57.