C++ UML类图C++结构

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19346532/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 22:44:33  来源:igfitidea点击:

UML Class diagram C++ struct

c++uml

提问by user1330627

How can I show struct members in the UML class diagram. In class diagram, I added struct as attribute and don't know how to add 'x', 'next' elements to that struct. if I generate the C++ from class diagram, it should have 'x' and 'next' elements in struct.

如何在 UML 类图中显示结构成员。在类图中,我添加了 struct 作为属性,但不知道如何向该结构添加 'x'、'next' 元素。如果我从类图中生成 C++,它应该在结构中包含 'x' 和 'next' 元素。

 class LinkList
    {
    private:
      // how to show the struct and its members in UML class diagram
      struct node
      {
         int x;
         node *next;
      }*p;

    public:
      // add an element
      void append(int num);

     // counts number of elements
      int count();
    };

回答by

something like this?! enter image description here

像这样的东西?! 在此处输入图片说明

and you would just remove the <<ptr>>stereotype and use the *as well, like +next:node*

你只需删除<<ptr>>刻板印象并使用*,就像+next:node*