Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!cimshop!davidm From: cimshop!davidm@uunet.UU.NET (David S. Masterson) Newsgroups: comp.std.c++ Subject: Re: protected != public-to-derived Message-ID: Date: 22 Mar 91 22:54:31 GMT References: <1991Mar19.165333.23908@asc.slb.com> Sender: davidm@cimshop.UUCP Distribution: comp Organization: Consilium Inc., Mountain View, California Lines: 25 In-reply-to: wkd@asc.slb.com's message of 19 Mar 91 16:53:33 GMT >>>>> On 19 Mar 91 16:53:33 GMT, wkd@asc.slb.com (Bill Duttweiler) said: Bill> Is it illegal to call a protected member function on an instance other Bill> than 'this'? Consider the following simple example: [...example deleted...] Bill> So, these compilers agree. But I don't: B is publicly derived from A Bill> and should have access to protected member functions from within its Bill> own member functions. I can call SetState() on 'this', why not on Bill> MyA??? This is a difficult question to answer in a short and sweet way. So, lets turn it around. Why should B have access to protected members of MyA since MyA is not in the inheritance chain of B (as opposed to A which is)? What differentiates this access from B attempting to access the protected members of some object MyC when B does not derive from C? -- ==================================================================== David Masterson Consilium, Inc. (415) 691-6311 640 Clyde Ct. uunet!cimshop!davidm Mtn. View, CA 94043 ==================================================================== "If someone thinks they know what I said, then I didn't say it!"