Error accessing protected member
Andrey Slepuhin
pooh@msu.ru
Sat Oct 18 11:51:00 GMT 1997
Hi,
Compiling the following code with egcs-971016:
-----------------------------------------
class A
{
protected:
void f(){}
};
class B :
public A
{
int c;
};
class C :
virtual public B
{
protected:
void f() { A::f(); }
};
void main ()
{
C x;
}
------------------------------
I get the following error message:
------------------------------
tmp.C: In method `void C::f()':
tmp.C:4: `void A::f()' is protected
tmp.C:17: within this context
-------------------------------
(This code is localized from OmniBroker 2.0b4, so it works
fine with most of C++ compilers and gcc-2.7.2 too)
Removing "virtual" all works fine. Virtuality of A->B inheritance
doesn't affect to compilation result.
I didn't find anything in new C++ draft that can explain such effect,
so it seems like egcs bug.
Andrey Slepuhin,
Moscow State University
More information about the Gcc-bugs
mailing list