I use Enterprise Architect for UML class diagrams. In a class diagram, there are many different arrows and I never know what to use for what.
The main ones are:
Associate: just a line
Generalize: a line with a triangle, I use this one for inheritance
Compose: a line with a black diamond
Aggregate: a line with a white diamond
(The other ones are less relevant I think)
I use the "Generalize" arrow for inheritance, and the "Compose" arrow for when something is a member.
Also, for the "Generalize" arrow, I put the triangle at the side of the class I inherit from, while for the "Compose" I put the diamond at the class that has got the member.
But I think it's not necessarily correct what I do with Compose, and explanations of UML are very, very, vague to me about what to do when a class is a member of another. It's as if in their explanations they try to avoid any wording that would make clear which side of the arrow is the member and the class containing the member. I also don't know the difference between compose and aggregate.
So, which arrows to use for the following C++ situations? In the code below, the classes are assumed to have more functions and members that I don't mention (instead of empty classes).
1.) Inheritance: This one is just a simple warmup

class A
{
};
class B : public A
{
};
2.) A member
class A
{
};
class B
{
A a;
};
3.) A pointer to a member --> does it matter here whether or not A "owns" this pointer (e.g. by deleting it in its dtor)?
class A
{
};
class B
{
A* a;
};
4.) a vector of members
class A
{
};
class B
{
std::vector<A> a;
};
5.) a vector of pointers
class A
{
};
class B
{
std::vector<A*> a;
};
6.) Using it as function parameter
class A
{
};
class B
{
void doSomething(A& a);
};
7.) Inheriting with the class in a template parameter
template<typename T>
class X
{
};
class A
{
};
class B : public X<A>
{
};
How should a class diagram in each of these cases look, according to those arrow types of enterprise architect?
Thanks!
