From 5408941450801662678 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,2d6fd861b068c0f7 X-Google-Attributes: gid109fba,public X-Google-Thread: f78e5,2d6fd861b068c0f7 X-Google-Attributes: gidf78e5,public X-Google-ArrivalTime: 2001-05-10 16:42:02 PST Path: archiver1.sj.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!212.74.64.35!colt.net!dispose.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail From: James Dennett Newsgroups: comp.std.c++,comp.lang.c++ Subject: Re: Inheritance Problems Date: Thu, 10 May 2001 23:41:35 GMT Approved: Fergus Henderson , moderator of comp.std.c++ Message-ID: <3AFB0CDB.BAC04339@acm.org> References: <3AFA4600.7656A271@wit.regiocom.net> X-Trace: mail2news.demon.co.uk 989538099 mail2news:5628 mail2news mail2news.demon.co.uk X-Complaints-To: abuse@demon.net X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov) X-Accept-Language: en MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 48 Xref: archiver1.sj.google.com comp.std.c++:4631 comp.lang.c++:61019 "O.Petzold" wrote: > > Hello, > > the follwoing code isn't working (with the gcc-2.95.2). > If I see the inharritance it should ! > > class A { > public: > void ModifyAnother(A* a2) { > b = 1; // is working > a2->b = 1; // woking as well > } > protected: > int b; > }; > > > class B : public A { > public: > void ModifyAnother(A* a2) { > b = 1; // is working > a2->b = 1; // not working > } > }; > > int main() { > B b; > } > > `int A::b' is protected > > Well but, B is derived from A !! > What says the standard about ? That objects of class B have access to protected parts of objects that are themselves of class B, not to any other objects which are A's (or instances of subclasses of A which aren't subclasses of B). -- James Dennett --- [ comp.std.c++ is moderated. To submit articles, try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ --- Please see the FAQ before posting. --- ] [ FAQ: http://www.research.att.com/~austern/csc/faq.html ]