@OderWat that's the hard part, finding a good real world example. Real world example are most of the time either too complicated for an example or not suitable, because they have a simpler or better solution, which does not use this interface implementation. And then there is also the risk that the example is from a domain the reader will probably not understand. A really good example is an example where the interface type is superior to both the inheritance based approach, **and** the generics based approach.
**Better than Generics:** * the function `foobar` should be somewhat complex, so that not using generics actually is an advantage. This could be done by having a complex macro call in the body that could eat some time of the compiler. You should know that a macro is evaluated after the generic instanciation. **Better than inheritance** * At least one interface implementation is part of some older library, where the auther that writes the interface has no acces to, and therefore can't add inheritance. * Or, the objects need to be very compact, so that adding a vtable to each object is a bad idea.