命令模式的设计:关键是将一个请求封装到一个command的类中,在提供处理对象Receiver;最后command命令有invoke激活
class Receive
{
public:
void execute()
{
}
}
class Command
{
private:Receive *m_re;
public:
virtual void execute()=0;
};
class ConcreteCommand:public Command
{
pulbic;
ConcreteCommand(Receive *re):m_re(re)
{
}
void execute()
{
re->execute();
}
};
class Invoke
{
private:
command * m_c;
public:
Invoke(command* c):m_c(c)
{}
void action()
{
m_c->execution();
}
}