Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!swrinde!ucsd!helios.ee.lbl.gov!ux1.lbl.gov!beard From: beard@ux1.lbl.gov (Patrick C Beard) Newsgroups: comp.lang.c++ Subject: Re: Private base class Summary: whoops, correction. Message-ID: <4606@helios.ee.lbl.gov> Date: 11 Jan 90 03:25:21 GMT References: <1533@castle.ed.ac.uk> <4604@helios.ee.lbl.gov> Sender: usenet@helios.ee.lbl.gov Reply-To: beard@ux1.lbl.gov (Patrick C Beard) Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 47 X-Local-Date: 10 Jan 90 19:25:21 PST In article <4604@helios.ee.lbl.gov> I write: [code example deleted] ##Compiling this with CC (cfront version 1.2.1) gives the following ##errors: ##CC test.c: ## ##"test.c", line 18: error: a is from private base class ##"test.c", line 19: error: f is from private base class ##2 errors # #As it should, you have inherited the base class privately. In other #words, all members, public, protected, or private, are inaccessible #to the derived class. # #derived : public base {...}; # #Redeclaring the members a and f can only make the visibility MORE strict, #not less. From the AT&T C++ reference manual (pp. 70-71): "If a class #is declared to be a base class for another class using the private access #specifier, the public and protected members of the base class are private #members of the derived class." By not specifying the access in the declaration #of the derived class, base is by default private. And, on the next page of the manual (sorry I didn't see this at the time of my last posting): class B { public: int a; private: int b; protected: int c; }; class D : private B { public: B::a; // make 'a' a public member of D. B::b; // make 'b' a public member of D (which is an error). protected: B::c; // make 'c' a protected member of D (ok). B::a; // make 'a' a protected member of D (error, reducing access). }; These are called "access declarations." Sorry for my confusion. ------------------------------------------------------------------------------- - Patrick Beard, Macintosh Programmer (beard@lbl.gov) - - Berkeley Systems, Inc. "..............Good day!" - Paul Harvey - -------------------------------------------------------------------------------