Design patterns implementation examples

Prototype

Definition:

Creates a new instance of an object by copying it from already existing instance (prototype).


Example:

A good example is copying instead of rewriting documents. We can use a copying machine - it is cheaper and faster.


C++ code:

/src/prototype.cpp
Download source code

Prototype UML class diagram:
Prototype UML class diagram

Prototype UML sequence diagram:
Prototype UML sequence diagram