其他分享
首页 > 其他分享> > 从零构建自己的远控•客户端设计面向对象(13)

从零构建自己的远控•客户端设计面向对象(13)

作者:互联网

#include <stdio.h>
#include <windows.h>

class CManager;


class CClientSocket
{
public:
    void setManagerCallBack(CManager* pManager);
    CManager* m_pManager;
    bool Connect();//每一个模块单独创建连接

};

void CClientSocket::setManagerCallBack(CManager* pManager)
{
    m_pManager = pManager;
}

class CManager
{
public:
    CManager(CClientSocket* pClient);
    
    CClientSocket* m_pClient;
    virtual void OnReceive();//不同dlg 进行虚写
};
CManager::CManager(CClientSocket* pClient)
{
    m_pClient = pClient;
    m_pClient->setManagerCallBack(this);
}


class CFileManager :public CManager//文件操作模块
{
public:
    CFileManager(CClientSocket* pClient);
     void OnReceive();//文件操作所有指令
};

CFileManager::CFileManager(CClientSocket* pClient):CManager(pClient)
{

}

void CFileManager::OnReceive()
{
    printf("更具服务器返回指令执行操作");
}

void CManager::OnReceive()
{
}

bool CClientSocket::Connect()
{
    m_pManager->OnReceive();
    return 0;
}


int main()
{//例子
    CClientSocket    socketClient;
    CFileManager    manager(&socketClient);
    socketClient.Connect();

    return 0;
}

 

标签:CManager,13,CClientSocket,void,pClient,pManager,远控,CFileManager,客户端
来源: https://www.cnblogs.com/feizianquan/p/15224957.html