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;
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 |
| |
|______________|
I am not quite sure if this is perfectly standard but this is the definition of your "A" class when I tried to reverse engineer it using Enterprise Architect:
+---------+
+-----| T:class |
| +---------+
| T |
| A |
+----------+
| |
+----------+
just add the name of the template parameter as the parent name of the class.
There is a proposal, by the UML designers, but, its not part of the standard, yet.
If, there wasn't any template parameters, the object "a" of type "A", may be like this:
+--------------------+
| a: A |
+--------------------+
| [+] doSomething(); |
+--------------------+
The object "a", who is a template of "a", with the type parameter "Foo", may be represented like this:
+-----+
+-----------------| Foo |
| +-----+
| a: A |
+--------------------+
| [+] doSomething(); |
+--------------------+
Note, that, in UML, 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.
Cheers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.