private inheritance

Public inheritance means that everyone knows that Derived is derived from Base.

Protected inheritance means that only Derived, friends of Derived, and classes derived from Derived know that Derived is derived from Base.*

Private inheritance means that only Derived and friends of Derived know that Derived is derived from Base.

Since you have used private inheritance, your main() function has no clue about the derivation from base, hence can’t assign the pointer.

Private inheritance is usually used to fulfill the “is-implemented-in-terms-of” relationship. One example might be that Base exposes a virtual function that you need to override — and thus must be inherited from — but you don’t want clients to know that you have that inheritance relationship.

*also: how much wood would a woodchuck chuck…

Leave a Comment