[Proposal]: Define how to inherit the properties from the parent class #4090
Replies: 3 comments 13 replies
-
Can you explain in more detail in what situations this would be useful? I especially don't understand how this makes sense, when As I understand it, C++ has a similar feature, but there it makes more sense since C++ has multiple inheritance and since "composition over inheritance" wasn't as popular when C++ was first designed. |
Beta Was this translation helpful? Give feedback.
-
You could not cast this to parent, making this just copying properties instead of polymorphic inheretance. |
Beta Was this translation helpful? Give feedback.
-
That breaks here:
You can't hide the members because they always be available through the subtypes that your type inherits from. You may want to consider an analyzer here. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
FEATURE_NAME
Inheritance behavior
Summary
To define how the behavior of the inheritance. By default, if A is inherited from B, the inheritance is
as public
by default. The developer can change this behavior toas protected
which converts all public properties of the parent class as private in the child class. Therefore, any new class that will be inherited from the child class will not be able to access the parent properties or methods. The developer still can allow some properties to be accessible by using the keywordnew
.Motivation
Always I have a problem with defining custom controls where I want to hide the inherited properties from any new child class of my custom control. I believe if we add a restriction or a behavior on the inheritance, it will solve the problem
Detailed design
Beta Was this translation helpful? Give feedback.
All reactions