lundi 9 janvier 2023

Decorator Pattern with added functions

I found this example for the decorator pattern in a text book.

Decorator pattern example

If we considered the object:

LockedStack MyStack = new LockedStack(new UndoStack(new Stack()))

How can I call the function undo on it?

MyStack.delegate.undo() won't work because delegate is private.

Does this example not work in this situation or am I missing something?

Aucun commentaire:

Enregistrer un commentaire