Author image

State Design Pattern

This is a demonstration of the State Design Pattern in C++ with a groovy example that will stick in your memory.

The state pattern allows an object to alter its behavior at runtime when its internal state changes. There is a base State class and various concrete derived state classes. The state class hierarchy makes up a state machine and the desired object can be at any one single state at a point in time. State is a very similar - a structural alternative - to the Strategy pattern.