command.h

来自「C++ Source code from a tutorial」· C头文件 代码 · 共 27 行

H
27
字号
#ifndef _COMMAND_H_
#define _COMMAND_H_

class Command {
public:
    virtual void Execute() = 0;
};

template <class CommandList>
class SpecificCommand : public Command {
protected:
    typedef void (CommandList::* Action)();
    Action action;
    CommandList *commandlist;
public:
    SpecificCommand(CommandList* c, Action a) { 
        commandlist = c;
        action = a;
    }
    void Execute() {
        (commandlist->*action)();
    }
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?