Default inheritance access specifier

Just a small addition to all the existing answers: the default type of the inheritance depends on the inheriting (derived) type (B in the example), not on the one that is being inherited (base) (A in the example).

For example:

class A {};
struct B: /* public */ A {};
struct A {};
class B: /* private */ A {};

Leave a Comment