How can I describe a class pointer in a UML class diagram?

If I have class Aone that contains a pointer to class Band a method into which a pointer toclass B

class A {
private:
    B* attribute;
public:
    void method(B* par);
}

How can I describe it in a UML class diagram? Do I use? What is this composition?

+5
source share
3 answers

In UML, it is not so important to show whether it is a pointer or not. What for? Because you can use UML that describes OOD for a language without pointers.

The quick answer: from your code, aggregates are B (an empty diamond in class A connecting B to the solid line). This is because there is no destructor that removes references to the A.attribute pointer.

, , . , ( ), , , () . . , . - . , .

(),, . , , , , . TeamLeadRole, "" (.. ), TeamLeadRole .

, , , ( ) . , , .

, ( /) , () . , .

+13

++ UML, :

enter image description here

() , :

enter image description here

"" . , "" , , , ( ). . 5 tutorial.

++ "*" UML,

  • Cpp-specific, , , ;
  • UML, , B-;
  • UML ( ).

A B . , . , : " ?" " ?" .

+3

*, [] UML. " ". , . , . , ! , , .

But note that the pointer / link field should be the default, so you don't need to indicate your case on the class diagram.

If you want to display this information correctly, use a more detailed diagram of the composite structure. There you can show these &, *, [] as you wish.

enter image description here

For different association options in the class diagram, see this my answer to a similar question: fooobar.com/questions/1015767 / ...

+2
source

Source: https://habr.com/ru/post/1015745/


All Articles