views:

95

answers:

1

I found those two terms in the book of Meyers, but what is the difference, thanks in advance for any help

+1  A: 

Interface inheritance is public inheritance, while implementation inheritance is private inheritance.

If class B publicly inherits from A, B is an A: it inherits the whole interface of A, and a (reference/pointer to) a B object can be automatically be upcasted to A, and used wherever an object of A is expected. However, if B privately inherits from A, B is-implemented-in-terms-of A: only the implementation of A is inherited, not its interface. Thus (references/pointers to) B objects can not be used in places where A objects are expected.

Péter Török
Note that `private` inheritance should only be used in a very restricted set of cases (mainly: virtual override / Empty Base Optimization). "Implementated in terms of" relationship is best implemented by composition.
Matthieu M.
@Matthieu, correct, thanks for mentioning.
Péter Török