This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Inheritance Problem
- To: opetzold at wit dot regiocom dot net (Olaf Petzold)
- Subject: Re: Inheritance Problem
- From: Joe Buck <jbuck at synopsys dot COM>
- Date: Thu, 10 May 2001 07:55:29 -0700 (PDT)
- Cc: gcc at gcc dot gnu dot org (GCC Mailing List)
> the follwoing code isn't working (with the gcc-2.95.2).
> If I see the inharritance it should !
Nope.
> 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
> }
> };
B does not have permission to change b in any A, but only in a B.
That is, if you had B* a2 it would be legal.