标签:编译 替代 信息 gif roc 干什么 RoCE ima 函数
概述
示例1
Command.cpp
1 #include <iostream> 2 #include <vector> 3 #include <string> 4 using namespace std; 5 6 class Command 7 { 8 public: 9 virtual void execute() = 0; 10 }; 11 12 class ConcreteCommand1 : public Command 13 { 14 string arg; 15 public: 16 ConcreteCommand1(const string & a) : arg(a) {} 17 void execute() override 18 { 19 cout<< "#1 process..."<<arg<<endl; 20 } 21 }; 22 23 class ConcreteCommand2 : public Command 24 { 25 string arg; 26 public: 27 ConcreteCommand2(const string & a) : arg(a) {} 28 void execute() override 29 { 30 cout<< "#2 process..."<<arg<<endl; 31 } 32 }; 33 34 class MacroCommand : public Command 35 { 36 vector<Command*> commands; 37 public: 38 void addCommand(Command *c) { commands.push_back(c); } 39 void execute() override 40 { 41 for (auto &c : commands) 42 { 43 c->execute(); 44 } 45 } 46 }; 47 48 int main() 49 { 50 51 ConcreteCommand1 command1(receiver, "Arg ###"); 52 ConcreteCommand2 command2(receiver, "Arg $$$"); 53 54 MacroCommand macro; 55 macro.addCommand(&command1); 56 macro.addCommand(&command2); 57 58 macro.execute(); 59 60 }
标签:编译 替代 信息 gif roc 干什么 RoCE ima 函数
原文地址:https://www.cnblogs.com/cxc1357/p/12324142.html