How to show private inheritance relationship in a UML class diagram

前端 未结 1 1160
遥遥无期
遥遥无期 2021-02-07 15:03

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

1条回答
  •  粉色の甜心
    2021-02-07 15:51

    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.

    0 讨论(0)
提交回复
热议问题