int main() { //invoker Invoker invoker; //command receiver--->the real object to execute command Light *light = new Light(); TV *tv = new TV(); //command LightCommand *lightCom = new LightCommand(); TVCommand *tvCom = new TVCommand(); lightCom->setReceiver(light); tvCom->setReceiver(tv); invoker.addCommand(lightCom); invoker.addCommand(tvCom); invoker.execute(); invoker.undo(); return 0; }
int main() { Invoker a; ConcreteCommand b, c, d; a.store(&b); a.store(&c); a.store(&d); a.execute(); return EXIT_SUCCESS; }