This is the mail archive of the gcc-bugs@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]

qualified access to protected base class members does not work


IMHO It is a bug. The following test program cannot be compiled while
I think it is a normal  C++ program. If you remove "A::" qualifier it is
compiled and  it works fine.

--------- inh.cpp ---------------------------------------

#include <stream.h>

class A
{
public:
    void op1(int i) { cout << "A::op1(" << i << ")" << endl; };
};

class B:
    protected A
{
};

class C:
    virtual public B
{
};

class D:
    virtual public B
{
};

class E:
    public C,
    public D
{
public:
    void op2(int i) { A::op1(i); }
};

int main()
{
    E * e = new E();
    e -> op2(5);
};
-------------------------------------------------------------------

Egcs produces the following output:

inh.cpp: In method `void E::op2(int)':
inh.cpp:6: `void A::op1(int)' has protected accessibility
inh.cpp:31: within this context

-------------------------------------------------------------------

EGCS version: 1.1.2
g++ --version  = "egcs-2.91.66"
bundled with RH 6.0, i586


Best Regards,
Victor Kamensky


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