#include <cstdlib>
#include <iostream>
using namespace std;
class Reciver
{
public:
virtual void Execute() = 0;
};
class ReciverConcrete:public Reciver
{
public:
virtual void Execute(){cout<<"ReciverConcrete do sth."<<endl;}
};
class Command
{
Reciver* pRecv;
public:
Command(Reciver* p):pRecv(p){}
~Command(){delete pRecv;}
void Execute(){pRecv->Execute();}
};
class Invoker
{
Command* pCom;
public:
Invoker(Command* p):pCom(p){}
~Invoker(){delete pCom;}
void Invoke(){pCom->Execute();}
};
void Do(Invoker* pInv)
{
pInv->Invoke();
delete pInv;
}
int main(int argc, char *argv[])
{
Do(new Invoker(new Command(new ReciverConcrete)));
system("PAUSE");
return EXIT_SUCCESS;
}
1633

被折叠的 条评论
为什么被折叠?



