G
Guest
The following code does not compile:
class X {};
class Y : private X {};
class Z : public Y
{
public:
Z(X&) {} // problem here
};
Both GCC 3.3 and Comeau Online give the same error:
test.cpp: In constructor `Z::Z(X&)':
test.cpp:1: error: `class X' is inaccessible
test.cpp:8: error: within this context
I can fix the error by changing the broken ctor to Z:X&) to
explicitly refer to the global class ::X, but I don't understand why I
have to. Can someone explain why private inheritance makes X
inaccessible in this situation?
Thanks.
class X {};
class Y : private X {};
class Z : public Y
{
public:
Z(X&) {} // problem here
};
Both GCC 3.3 and Comeau Online give the same error:
test.cpp: In constructor `Z::Z(X&)':
test.cpp:1: error: `class X' is inaccessible
test.cpp:8: error: within this context
I can fix the error by changing the broken ctor to Z:X&) to
explicitly refer to the global class ::X, but I don't understand why I
have to. Can someone explain why private inheritance makes X
inaccessible in this situation?
Thanks.