How to show private inheritance relationship in a UML class diagram

霸气de小男生 提交于 2020-12-29 03:02:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!