Path: utzoo!telly!ddsw1!lll-winken!uunet!tut.cis.ohio-state.edu!PARIS.ICS.UCI.EDU!schmidt%crimee.ics.uci.edu From: schmidt%crimee.ics.uci.edu@PARIS.ICS.UCI.EDU ("Douglas C. Schmidt") Newsgroups: gnu.g++.bug Subject: Re: g++ 1.32 is lax on protection Message-ID: <8901270106.aa24874@PARIS.ICS.UCI.EDU> Date: 27 Jan 89 09:05:34 GMT References: <8901270021.aa08266@ICS.UCI.EDU> Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 63 > I thought that was the point of `protected' vs. `private'. If you change > to private you get the error. > > beshers@carcvax.brc.uconn.edu Hi, I believe you're getting confused by the following (which is admittedly weird at face value): ---------------------------------------- class foo { protected: int i; }; main () { foo bar; bar.i = 10; // error, protected members are not // visible to objects of the base // type. } g++ correctly says: ---------------------------------------- In function int main (): test.c:11: member `i' is a protected member of class `foo' ---------------------------------------- However, the following *is* correct: ---------------------------------------- class foo { protected: int i; }; class bar : public foo { public: f () { i = 10; // OK, since bar is a derived type } }; ---------------------------------------- If you look at the example I showed (from Stroustrup's article, so it had *better* be correct ;-)), you'll see that ---------------------------------------- X a; a.prot ---------------------------------------- is clearly trying to get ahold of the protected member, in the same illegal sense of my first example above. After all, ``a is not a Y!'' Does that make any more sense? Doug