From -3450937306027255664 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 11:07:01 PST Path: 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: "M. Kools" Newsgroups: comp.std.c++,comp.lang.c++ Subject: Re: Inheritance Problems Date: Thu, 10 May 2001 18:06:06 GMT Organization: EuroNet Internet Approved: Fergus Henderson , moderator of comp.std.c++ Message-ID: <9deksp$2qvf$1@scavenger.euro.net> References: <3AFA4600.7656A271@wit.regiocom.net> X-Trace: mail2news.demon.co.uk 989517971 mail2news:2906 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) NNTP-Posting-Date: Thu, 10 May 2001 17:58:50 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Lines: 50 Xref: newsfeed.google.com comp.std.c++:4713 comp.lang.c++:62684 "O.Petzold" schreef in bericht news:3AFA4600.7656A271@wit.regiocom.net... > 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 ? > > Thanks > Olaf > you're making a pointer to a new object, and this can't access the variable b cuz it's protected. --- [ 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 ]