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?
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.
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 '−'.
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.
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.
It should be a Composition relationship (solid black diamond on the subclass side), because:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With