设计模式――代理模式(Proxy)(二)

2014-11-24 01:35:54 · 作者: · 浏览: 4
KillBoss();
}
void CGamePlayerProxy::Upgrade()
{
mp_game_palyer->Upgrade();
}
3.4 Client
[cpp]
#include
#include "IGamePlayer.h"
#include "CGamePlayer.h"
#include "CGamePlayerProxy.h"
using std::cout;
using std::endl;
int main()
{
CGamePlayer game_palyer(string("Jone"), string("passwd"));
game_palyer.Login( string("Jone"), string("passwd") );
game_palyer.KillBoss();
game_palyer.Upgrade();
//////////////////////////////////////////////////////////////////////////
cout<<"\n\n"<
CGamePlayer* p_player = new CGamePlayer( string("Jone"), string("passwd") );
CGamePlayerProxy* p_proxy = new CGamePlayerProxy( p_player);
p_proxy->Login( string("Jone"), string("passwd") );
p_proxy->KillBoss();
p_proxy->Upgrade();
return 0;
}
3.5 运行结果