如何从 UML 中的模板参数表示继承? [英] How can I represent inheritance from a template parameter in UML?

查看:31
本文介绍了如何从 UML 中的模板参数表示继承?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用UML,我如何表示A<Foo > 在下面的代码中?

Using UML, how can I represent A< Foo > in the following code?

template< class T > 
class A : public T
{
    /* ... */
};

class Foo { };

A< Foo > a_foo;

这样的事情(为糟糕的 ascii 艺术道歉......以及Jon Skeet) 是我的第一个猜测,但我怀疑它不正确.

Something like this (apologies for the poor ascii art... and to Jon Skeet) is my first guess, but I suspect it is not correct.

            ________________
            |              |
            |              |
            |     Foo      |
            |              |
            |______________|
             /:\  /|\
«bind»(Foo)   :    |
              :    |   .......               
            __:____|___:  T  :
            |          :.....:
            |              |
            |      A       |
            |              |
            |______________|

推荐答案

有一个提案,由 U.M.L.设计师,但是,它还不是标准的一部分.

There is a proposal, by the U.M.L. designers, but, its not part of the standard, yet.

如果没有任何模板参数,A"类型的对象a"可能是这样的:

If, there wasn't any template parameters, the object "a" of type "A", may be like this:

+--------------------+
|        a: A        | 
+--------------------+
| [+] doSomething(); |
+--------------------+

对象a",是a"的模板,带有类型参数Foo",可以这样表示:

The object "a", who is a template of "a", with the type parameter "Foo", may be represented like this:

                  +-----+
+-----------------| Foo |
|                 +-----+
|        a: A        | 
+--------------------+
| [+] doSomething(); |
+--------------------+

请注意,在 U.M.L. 中,当您声明一个类时,它们由一个矩形表示,而特定的对象,例如a",则由带有圆角的矩形表示.有些人,&工具,不遵循圆角"规范.

Note, that, in U.M.L., when you declare a class, they are represented by a rectangle, while specific objects, such "a", are represented by rectangle with round corners. Some people, & tools, doesn't follow the "round corners" specification.

干杯.

这篇关于如何从 UML 中的模板参数表示继承?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆