class Base
{
};
class Derived : private Base
{
void foo()
{
Derived d;
Base* p = &d; // OK to do here, because we're in Derived
// and Derived has access to Derived's Base
// (Derived can access private stuff in Derived)
}
};
int main ()
{
Derived d;
Base* p = &d; // illegal here (compiler error)
// because main cannot access private stuff in Derived
// and Base is private in Derived
return 0;
}
thanks for the example. Your explanation is cool. coz Base is private in Derived, so the Base pointer p has no access to the private component of Derived, just as any other private member in Derived, if it has any.
@ Disch: Security tokens for Access Control Lists... That's all I've got, and yeah I know this is an oddly specific example but it's a task that is perfect for private\protected inheritance and polymorphism in general.