问题
How to exemplify that a class can inherit either of two super-classes, but not both?
The class Property can either represent a Set of numbers, or a Cardinal number, BUT not both at the same type.
回答1:
Your sub classing is upside down. You need a Set Property
and a Cardinal Property
that specialize Property
. If those subclasses also have characteristics of Set
and Cardinal
, you could subclass those as well.
来源:https://stackoverflow.com/questions/38830845/how-to-express-mutually-exclusive-inheritance-in-uml