In C++/CLI, I want a class hierarchy similar to the following:
Foo
FooA : Foo, ClrClassA
FooB : Foo, ClrClassB
Is it possible for FooA to share a (non CLR) base class while also inheriting from separate CLR classes? If not, what would be the best way for FooA and FooB to share common code?
Generally speaking, composition is often better than inheritance as it tends to lead to less tightly coupled designs.
If you’re mixing managed and unmanaged code, it’s generally easier in my experience to wrap unmanaged code in managed code rather than visa versa.
Multiple inheritance isn’t supported for managed code and there’s an article on Wikipedia which explains why:
It’s difficult to give a good answer as to how best to combine your classes / functionality without knowing why you want to combine the classes…