Object Composition - UML Notation

UML Notation

In UML, composition is depicted as a filled diamond and a solid line. It always implies a multiplicity of 1 or 0..1, as no more than one object at a time can have lifetime responsibility for another object.

The more general form, aggregation, is depicted as an unfilled diamond and a solid line. The image below shows both composition and aggregation. The C++ code below shows what the source code is likely to look like.

// Composition class Car { private: // Car is the owner of carburetor, it is created when Car is created, // it is destroyed when Car is destroyed Carburetor carb; }; // Aggregation class Pond { private: std::vector ducks; };

Read more about this topic:  Object Composition