Design patterns implementation examples

Memento

Definition:

Saves inner state of object in order to restore it in future.


Example:

For instance we are playing some game and someone comes in with something important. We can save the game and restore it when we have time to play again.


C++ code:

/src/memento.cpp
Download source code

Memento UML class diagram:
Memento UML class diagram

Memento UML sequence diagram:
Memento UML sequence diagram