6

Let's say I have the following relationship:

class A {
public:
   A(B& _objB);
   B& objB;
};

A::A(B& _objB)
 : objB(_objB) {}

This doesn't seem to fit with my understanding of the UML definitions of aggregation or composition. It feels like a composition, but in a composition the lifetime of the owned object should be tied to the parent object. In this case objB exists before A is created and after A is destroyed. A can't live without B, but B can live without A. This is the reverse of the standard composition relationship. Does that make it an aggregate or something else?

1 Answers1

1

Already answered here , the answer is aggregation. a none owning usage of B.

Community
  • 1
  • 1