I have defined an "Action" pure abstract class like this:
class Action {
public:
virtual void execute () = 0;
virtual void revert () = 0;
virtual ~Action () = 0;
};
And represented each command the user can execute with a class.
For actual undo/redo I would like to do something like this:
Undo
Action a = historyStack.pop();
a.revert();
undoneStack.push(a);
Redo
Action a = undoneStack.pop();
a.execute();
historyStack.push(a);
The compiler obviously does not accept this, because "Action" is an abstract class which can not be istantiated.
So, do I have to redesign everything or is there a simple solution to this problem?