问题
In C++ since private inheritance is not considered as an is-a
relationship, how is it supposed to be shown in a class diagram and if it is shown as a has-a
relationship then how can it be differentiated between a composition and a private inheritance?
回答1:
It should be a Composition relationship (solid black diamond on the subclass side), because:
- Private inheritance means "implemented in terms of" but in this regard it can be simply treated the same as "has a" relationship.
- An instance of the subclass clearly owns the base calss part of the object, and the ownership is not shared with any other objects.
来源:https://stackoverflow.com/questions/9415350/how-to-show-private-inheritance-relationship-in-a-uml-class-diagram