Say I have a bunch of code for all controls, yet I need subclasses that interact with my software suite to use those common methods. I really want my subclass to derive from the control, not the class with the common code. (A MyEdit should derive from Edit, not from MyControl). Also, the suite interacts with controls using an interface which MyControl derives from. In order to do this in C++, I would use multi-inheritance like so
class MyEdit : public Edit, public MyControl;
class MyControl : public IControl;
However, I suddenly discover that I shouldn’t use multi-inheritance if I want some controls to be C# which doesn’t support multi-inhertiance.
So I thought I could do this…
class MyEdit : public MyControl<Edit>;
template class MyControl<Type> : public IControl;
Convert the common control stuff into a template, and give it the type of control I want to derive from.
However I’m not sure this will work, because the template templatizes Edit, but it doesn’t necessarily create one does it? When I create the template will I actually be able to create the Edit?
And secondly, if this is possible, is it possible in C#? What would it look like?
I can’t say I quite followed your question, but in regards to:
I would go for
so that
MyControl<Edit>inheritsEdit(which is created) and the interface