【发布时间】:2013-10-13 14:53:24
【问题描述】:
如何在 UML 类图中显示结构成员。在类图中,我将结构添加为属性,但不知道如何向该结构添加“x”、“下一个”元素。如果我从类图中生成 C++,它应该在 struct 中有 '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();
};
【问题讨论】:
-
由于节点是一个实现细节,我会在任何 UML 图中省略它。他们可以变得足够拥挤。从 UML 生成 C++ 只是一个愚蠢的想法。