class Foo{};
class Demo
{
public:
std::shared_ptr<Foo> foo_ptr{new Foo()};;
};
What's the relationship between Foo and Demo? I think it is an aggregation. Am I right? How to draw such the relationship between them?
class Foo{};
class Demo
{
public:
std::shared_ptr<Foo> foo_ptr{new Foo()};;
};
What's the relationship between Foo and 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. The association is moreover navigable from Demo to Foo.
Be we can't tell more with certainty:
shared_ptr could implement a shared aggregation (hollow diamond). 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). In practice, there is no real benefit to use shared aggregation over a simple association in a model.shared_ptr could in theory even be used to implement composite aggregation. It's not very likely, even less with a public pointer. But, in theory, the code could ensure that only a single shared_ptr is active for a given component. This would not be immediately visible and would require some code analysis, but cannot be excluded at least if the shared_ptr would be private.