This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Inheritance Problem
- To: GCC Mailing List <gcc at gcc dot gnu dot org>
- Subject: Inheritance Problem
- From: Olaf Petzold <opetzold at wit dot regiocom dot net>
- Date: Thu, 10 May 2001 10:35:35 +0200
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's going on here ?
Thanks
Olaf