I have a base class defining a constant and the child class can use it using alias. The construct is as below
class Base
{
protected:
static const int A_ = 1;
};
class Foo : public Base
{
private:
using Base::A_;
};
However, when I define a subclass of Foo as
class Go : public Foo
{
private:
using Base::A_;
};
the compiler emits the error: error: ‘const int Base::A_’ is private within this context. I do not get it since Base::A_ is protected. What did the compiler see in this case and what can be the solution to use Base::A_ in Go ?
Goinherits fromFoonot fromBase.A_is private inFoonot protected.If you want to have access to
A_in classes derived fromFoothenA_should bepublicorprotectedinFoo.