How to represent C++ new() operator using UML
I want know how to represent the C++ new() operator 开发者_如何学运维using UML Class Diagram. For example, if I have:
Class B
{
...
}
Class A
{
void exampleMethod()
{
B *test = new B();
}
}
You can depict it in the following way:
The class diagram is a structural view of the system, so you won't normally see any representation of the behaviour of methods in it.
You can add it as body tag or comment depending on the tool, or associate a sequence diagram containing a «create» message with the method as Als suggests.
Using a class diagram you can use a directed associaton with the stereotype <<instantiate>>
, see the following example:
精彩评论