The decorator pattern can be used to extend (decorate) the functionality of a certain object statically, or in some cases at run-time, independently of other instances of the same class, provided some groundwork is done at design time. This is achieved by designing a new Decorator class that wraps the original class. This wrapping could be achieved by the following sequence of steps:
Subclass the original Component class into a Decorator class (see UML diagram);
In the Decorator class, add a Component pointer as a field;
In the Decorator class, pass a Component to the Decorator constructor to initialize the Component pointer;
In the Decorator class, forward all Component methods to the Component pointer;
In the ConcreteDecorator class, override any Component method(s) whose behavior needs to be modified.