caduel
22nd July 2009, 20:51
I have a class hierarchy that contains amongst others
class Dialog { ... };
class SpecialDialog : public Dialog { ... };
I also have a class
class ListDialog : public Dialog { ... };
The functionality of "ListDialog" does not depend on the extensions of SpecialDialog, it would have been possible to have it extend SpecialDialog as well.
And that is just my question:
Going from the (already implemented) above classes, is there an easy way to have both a ListDialog and a "SpecialListDialog" that is identical but inherits SpecialDialog instead. (Ideally the solution should allow even further "Dialog"-based classes as subclasses.
I would hate to copy the source and just change the few references to the base class (mostly in virtual methods). I also don't like too many implementation details in headers (otherwise I'd make a template)...
I am aware that I could put the complete implementation into the header and make the class a template and the base class a template parameter. (I am looking for a different solution, if possible.)
Another idea would be to try to put the extension of ListDialog into a separate class and use multiple inheritance. But how would you override the virtual functions, then? (Yes, Dialog does contain virtual methods which are overridden in ListDialog..)
Best regards and thank you for your ideas.
(A similar problem is when you want to extend two different (existing) Qt widgets by common functionality...)
class Dialog { ... };
class SpecialDialog : public Dialog { ... };
I also have a class
class ListDialog : public Dialog { ... };
The functionality of "ListDialog" does not depend on the extensions of SpecialDialog, it would have been possible to have it extend SpecialDialog as well.
And that is just my question:
Going from the (already implemented) above classes, is there an easy way to have both a ListDialog and a "SpecialListDialog" that is identical but inherits SpecialDialog instead. (Ideally the solution should allow even further "Dialog"-based classes as subclasses.
I would hate to copy the source and just change the few references to the base class (mostly in virtual methods). I also don't like too many implementation details in headers (otherwise I'd make a template)...
I am aware that I could put the complete implementation into the header and make the class a template and the base class a template parameter. (I am looking for a different solution, if possible.)
Another idea would be to try to put the extension of ListDialog into a separate class and use multiple inheritance. But how would you override the virtual functions, then? (Yes, Dialog does contain virtual methods which are overridden in ListDialog..)
Best regards and thank you for your ideas.
(A similar problem is when you want to extend two different (existing) Qt widgets by common functionality...)