Composed Inheritance #115401
Unanswered
UniqeId6542
asked this question in
Ideas
Composed Inheritance
#115401
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I sometimes want to mix and match independent features, but find that the ownership requirement of using composition makes that option less viable.
For example, suppose I define the following 3 classes:
If I wanted to make a MagicSwordsman using composition, I would run into issues of making the methods public while also accessing the base class's property. (Yes, it CAN be done. But it gets looking more like a hack.)
If, instead, I could inherit from a generic type (support what currently makes the CS0689 error), I could have:
(With interfaces, MagicSwordsman could also follow the pattern. That, or allowing a constraint of more than one class.)
Composed Inheritance vs. Inheritance
Composed Inheritance vs. Composition
Composed Inheritance vs. Extension Methods
(Yes, this is the same as my previous post; but with a different approach to the description. #79887)
Could support for this be added to .NET / C#?
Beta Was this translation helpful? Give feedback.
All reactions