impl
has two entirely separate methods, iface::foo
, which is pure, and wrapped::foo
. There's no name resolution — virtual function calls are dispatched by a structure called vtable, which holds pointers to implementations. A class has separate vtable for each of its direct ancestors, at least in cases without virtual inheritance. Synonymous virtual functions from different ancestors end up in different vtables; the compiler has no way of "combining" them. C++ doesn't have mixins.
Obviously, I can avoid the error by writing a concrete implementation of foo in impl that forwards to wrapped::foo()
Better yet, don't use double inheritance — do something like
struct impl : public iface
{
virtual void foo ()
{
wr.foo ();
}
private:
wrapped wr;
};