Posted on 2008-12-20 23:57
S.l.e!ep.¢% 閱讀(1586)
評論(4) 編輯 收藏 引用 所屬分類:
Design Pattern
class CServerContext
{
public:
??? CServerContext();
??? ~CServerContext();
};
它需要有寫Log的功能, 于是
class CServerContext : public ILogInterface
{
public:
??? CServerContext();
??? ~CServerContext();
??? virtual void log(const char* pszLog);
};
它也需要網絡通信的功能, 于是
class CServerContext : public ILogInterface,? public INetWorkInterface
{
public:
??? CServerContext();
??? ~CServerContext();
??? virtual void log(const char* pszLog);
??? virtual void send(const void* pBuf, int nSize);
??? virtual void onrecv(const void* pBuf, int nSize);
};
它還需要訪問數據抽象層的功能,于是乎
class CServerContext : public ILogInterface,? public INetWorkInterface
??????????????????????????????????? puclic IDBAbstractLayer
{
public:
??? CServerContext();
??? ~CServerContext();
??? virtual void log(const char* pszLog);
??? virtual void send(const void* pBuf, int nSize);
??? virtual void onrecv(const void* pBuf, int nSize);
????virtual?bool writeData(int nData);
??? virtual int??? readData();???
};