[英]Class diagram for variable member with the type of `std::shared_ptr<T>`
class Foo{};
class Demo
{
public:
std::shared_ptr<Foo> foo_ptr{new Foo()};;
};
What's the relationship between Foo and Demo? Foo和Demo有什么关系? I think it is an aggregation.
我认为这是一个聚合。 Am I right?
我对吗? How to draw such the relationship between them?
怎么画出他们之间这样的关系呢?
On thing is sure: the shared_ptr
implements an association.可以肯定的是:
shared_ptr
实现了一个关联。 The association is moreover navigable from Demo
to Foo
.该关联还可以从
Demo
导航到Foo
。
Be we can't tell more with certainty:我们不能确定地说更多:
shared_ptr
could implement a shared aggregation (hollow diamond). shared_ptr
可以实现共享聚合(空心菱形)。 But we can neither confirm nor infirm, because the UML specs do not define the semantics of shared aggregation (I know, it's difficult to believe given its heavy use).shared_ptr
could in theory even be used to implement composite aggregation. shared_ptr
理论上甚至可以用于实现复合聚合。 It's not very likely, even less with a public pointer.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.