Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!husc6!ukma!tut.cis.ohio-state.edu!ucbvax!agate!saturn!daniel From: daniel@saturn.ucsc.edu (Daniel Edelson) Newsgroups: comp.lang.c++ Subject: multiple inheritance Keywords: nits, multiple inheritance Message-ID: <7105@saturn.ucsc.edu> Date: 12 May 89 21:44:32 GMT References: <203@riunite.ACA.MCC.COM> <1527@cod.NOSC.MIL> <14133@paris.ics.uci.edu> Reply-To: daniel@saturn.ucsc.edu (Daniel Edelson) Organization: Univ of Calif, Santa Cruz; Computer & Info Sci Lines: 59 ++ my comments -- daniel Within <14133@paris.ics.uci.edu> Doug Schmidt asks: >Here's a quick nit. Is the following a legal use of multiple inheritance? ++ I believe not. > As you can see, from one direction class a's member >function `int foo ()' is private for all classes derived from class b. >However, on another path it is public. In class d's constructor, >where `foo ()' is called, foo appears to be derived from classes where >it is both private and public. ++ Private is private, is it not? If the field is private in a base class ++ then it is not available outside of member functions of that class. ++ Your question applys if you use protected instead of private. >Which visibility status prevails? Is this ambiguous, legal, or illegal? >thanks, Doug > class a { > public: > int foo () { printf ("foo\n"); } > }; ++ I changed ``private'' to ``protected'' in classes b and d > class b : public a { > protected: > a::foo; // made protected for all classes derived from class b. > }; > class c : public a { > public: > c () {printf ("c\n");} > }; > class d : public c, public b { > public: > // both public *and* private!! which prevails? > d () { printf ("d\n"); foo (); } > }; ++ My understanding is that if the call is ambiguous it's a ++ syntax error. That might not apply in this case since this is ++ the same function being inherited along two different paths of ++ the DAG. Is this ambiguous, or since it's a single function ++ being referred to twice, is it allowed? If the latter, what ++ happens when it is made virtual? If the former, it can be ++ disambiguated with the :: operator. >| schmidt@ics.uci.edu | ++ Well, I wanted to answer the question but all I've done is ++ ask new ones. daniel edelson daniel@saturn.ucsc.edu