[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: accessing protected members of a parent class
From: Patrick Julien <freak () ideasandassociates ! com>
Date: 2002-04-04 16:40:50
[Download RAW message or body]
you have to make B a friend in the protected or private section of class A.
Ellis Whitehead wrote:
> Is it possible to access protected members in an object whose type is a
> superclass of the current method's class? Somehow in over ten years of C++
> programming, I've missed or forgotten the fact that this isn't allowed. :(
>
> Compiling the following code, for example, results in the following error:
>
> $ g++ test.cpp -o test.o
> test.cpp: In method `void B::link(A *)':
> test.cpp:4: `void A::link(A *)' is protected
> test.cpp:15: within this context
>
>
> class A
> {
> protected:
> virtual void link( A* );
> };
>
> class B : public A
> {
> protected:
> virtual void link( A* );
> };
>
> void B::link( A* a )
> {
> a->link( 0 ); // *** fails ***
> }
>
>
>
>>>Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
>>
--
Patrick Julien
Ideas & Associates
(514) 940-2891x211
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic