标签:style blog http color 使用 strong
定义
class MenuItem {public:void setCommand(Command* comand) { m_command = command; }void onClicked() {m_command->execute();}private:Command* command;}class Command {public:virtual void execute();virtual bool isEnable();};class CopyCommand {public:virtual void execute() {m_receiver->action();}private:CopyReceiver* m_receiver;};class DeleteCommand {public:virtual void execute() {m_enable = m_receiver->action();}bool isEnable() {return m_enable;}private:DeleteReceiver* m_receiver;bool m_enable;};
MenuItem* copyItem = new MenuItem("Copy");MenuItem* deleteItem = new MenuItem("Delete");MenuItem* undoItem = new MenuItem("Undo");Button* copyButton = new Button("Copy");Button* deleteButton = new Button("Delete");Button* undoButton = new Button("Undo");Command* copyCommand = new CopyCommand();Command* deleteCommand = new DeleteCommand();Command* undoCommand = new UndoCommand();copyItem->setCommand(copyCommand);deleteItem->setCommand(deleteCommand);undoItem->setCommand(undoCommand);copyButton->setCommand(copyCommand);deleteButton->setCommand(deleteCommand);undoButton->setCommand(undoCommand);

标签:style blog http color 使用 strong
原文地址:http://blog.csdn.net/harrising/article/details/37702405