- Ignore the fact that the superclass has the property by not using it in any of the subclass methods.
- Split the superclass into two classes, one with properties A and B and one with property C. Modify existing subclasses to inherit from both and write your new subclass so it only inherits from the former.
- Rethink your inheritance hierarchy: if all superclass objects must have property C and your subclass cannot have property C, your subclass would violate the Liskov substitution principle.
Create subclass but doesn't need 1 superclass property
4 次查看(过去 30 天)
显示 更早的评论
My superclass has property [a, b, c]
If I decide to inherite a subclass from it, but doesn't need the superclass property [C],
is there a easier way to achieve it?
0 个评论
回答(1 个)
Steven Lord
2022-9-30
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subclass Definition 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!