UML类图C ++结构

问题描述:

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

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.

 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();
    };


是这样的吗?

something like this?!

您只需删除<< ptr>> 原型,并使用 * ,例如 + next:node *

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