This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Inheritance Problem



> 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.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]