As per this answer , class template could be represented like this:
___________: T :
| :.....:
| |
| ClassName |
| |
|______________|
Then how to represent the composition relationship with class template?
For example, given
template <typename T>
class FooRes
{
public:
T res;
bool valid;
};
,how to represent the relationship with the classes below?
class Demo
{
public:
int height;
int width;
int area;
};
class MultiRes
{
private:
FooRes<Demo> res1;
FooRes<int> res2;
FooRes<double> res3;
};
I think a class diagram for the said example could make it clear enough.
Could somebody shed some light on this matter?
In this answer to your other question , I developed the different ways to represent templated classes and their instantiation. You could use any of them for MultiRes
, except that you would have several instantiations of a template instead of a single one.
You could use a similar technique here, but brought to the next level of compactness:
FooRes
with parameter T
and show how it related to this abstract T
.MultiRes
The first would facilitate showing the links to the types used as template parameter. It would look like:
The second would look much more compact:
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.