Design patterns implementation examples

Composite

Definition:

Treats individual objects and compositions of objects in the same way.


Example:

An example from life is a computer file system. In a directory there might be other files and directories again. Operations such as deleting or copying can be done on individual files as well as on directories.


C++ code:

/src/composite.cpp
Download source code

Composite UML class diagram:
Composite UML class diagram

Composite UML sequence diagram:
Composite UML sequence diagram