Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show private inheritance relationship in a UML class diagram

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?

like image 626
ahj Avatar asked Feb 23 '12 14:02

ahj


People also ask

How do you show inheritance in UML diagram?

Inheritance is shown in a class diagram by using a solid line with a closed, hollow arrow. Bidirectional association: The default relationship between two classes. Both classes are aware of each other and their relationship with the other. This association is represented by a straight line between two classes.

How do you represent private in class diagram?

In class diagram, it is prefixed by the symbol '+'. Private − A private member is visible only from within the class. It cannot be accessed from outside the class. A private member is prefixed by the symbol '−'.

How will you display relationship in UML class diagram?

To show a composition relationship in a UML diagram, use a directional line connecting the two classes, with a filled diamond shape adjacent to the container class and the directional arrow to the contained class.

Do UML diagrams show private functions?

In general UML provides a mechanism to show operation (and attribute alike) visibility. As private feature can be depicted on a diagram it is clear that you can present it on a diagram. However if you show it or not depends what you're modelling. If you're modelling the internal behaviour of the class then yes.


1 Answers

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.
like image 60
H Xu Avatar answered Oct 12 '22 14:10

H Xu