[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: accessing protected members of a parent class
From: Ellis Whitehead <kde () ellisw ! net>
Date: 2002-04-04 16:41:03
[Download RAW message or body]
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 <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic