home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 18132 < prev    next >
Encoding:
Internet Message Format  |  1992-12-17  |  1.5 KB

  1. Path: sparky!uunet!noc.near.net!hri.com!spool.mu.edu!umn.edu!csus.edu!borland.com!pete
  2. From: pete@borland.com (Pete Becker)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Private base classes
  5. Message-ID: <1992Dec17.171343.26787@borland.com>
  6. Date: 17 Dec 92 17:13:43 GMT
  7. References: <921216205429_76336.3114_EHJ34-2@CompuServe.COM>
  8. Sender: news@borland.com (News Admin)
  9. Organization: Borland International
  10. Lines: 29
  11. Originator: pete@genghis.borland.com
  12.  
  13. In article <921216205429_76336.3114_EHJ34-2@CompuServe.COM> 76336.3114@CompuServe.COM (Kevin Dean) writes:
  14. >In the excitement generated by the fact that someone had managed to post
  15. >to comp.lang.c++ from CompuServe, the intent of my original posting was
  16. >lost.  Here it is again:
  17. >
  18. >I tried to do the following:
  19. >
  20. >class A {};
  21. >class B : private A {};
  22. >class C1 : public B, public A {};
  23. >
  24. >My compiler naturally warned me about A being both a direct and indirect
  25. >base class of C1 and so refused to compile it.  I was able to get around
  26. >the problem:
  27. >
  28. >class CA : public A {};
  29. >class C2 : public B, public CA {};
  30. >
  31. >My first thought, however, was that the declaration of C1 should have
  32. >been allowed.  If A is a private base class of B, no class derived from B
  33. >can access A so there should be no ambiguity in accessing members of A
  34. >from C1: the only A visible is the direct base class of C1.
  35.  
  36.     No.  The only A _accessible_ from C1 is the direct base.  Both A's
  37. are visible. The rule is that ambiguities are detected before applying
  38. access restrictions.  That's so that changing an access specifier won't
  39. result in ambiguities.
  40.  
  41.     -- Pete
  42.