Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!dptg!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.c++ Subject: Re: Why can't access control be used to disambiguate between base class members? Message-ID: <9716@alice.UUCP> Date: 1 Aug 89 15:40:39 GMT References: <2408@ginosko.samsung.com> <13073@polyslo.CalPoly.EDU> Distribution: na Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 36 In article <13073@polyslo.CalPoly.EDU>, ttwang@polyslo.CalPoly.EDU (Thomas Wang) writes: > We need name conflict resolution, because class A may be supplied by AT&T, and > class B may be supplied by IBM. Both classes come with compiled object code > and class header. Joe the programmer then must make class C from class A and > class B. In this case, the modification and re-compilation of both class A > and class B are impossible. I don't quite see why this causes a problem. There's nothing wrong with having members with the same name in two different base classes as long as you don't try to access one of those members in an ambiguous way. If they're private, presumably you won't. Example: struct A { int x; }; struct B { int x; }; struct C: A, B { }; void foo() { A a; B b; C c; a.x = 3; // OK b.x = 4; // OK c.x = 5; // error -- ambiguous c.A::x = 5; // OK c.B::x = 5; // OK } Of course, if C has a member named x, then C::x is unambiguous. -- --Andrew Koenig ark@europa.att.com