In this answer to the question “Why can't my object protect the protected members of another object defined in a common base class?”, You can read:
Access to protected members is available only from their own instance of the base class.
Either I don't get it right, or after MCVE (live on coliru) proves it wrong:
struct Base { void f(); protected: int prot; };
struct Derived : Base { void g(); private: int priv; };
void Base::f()
{
Base b;
b.prot = prot;
(void) b;
}
void Derived::g()
{
{
Derived d;
(void) d.priv;
}
{
Derived& d = *this;
(void) d.priv;
}
{
Derived d;
(void) d.prot;
}
{
Derived& d = *this;
(void) d.prot;
}
{
Base b;
(void) b.prot;
}
{
Base& b = *this;
(void) b.prot;
}
}
: , Derived, Derived, , Base, , , , Derived Base? Tl; dr: protected "private" private ?
: