I'd make class A and class B into mixin templates instead.
mixin template A { string a() { return "foo"; } } mixin template B { string b() { return "bar"; } } class C { mixin A; mixin B; }If you still need class A and class B, just make a class that mixes in the template for them too.
Since the C++ methods aren't virtual, I imagine you don't really need a base class for them, but if you do want a virtual base class, make interfaces and inherit from as many of them as you need.