我不知道CList怎么定义,在网络上看了很多内容,但是还是不能解决自己的问题,希望高手解决下面是头文件MyQQServerDlg.h// MyQQServerDlg.h : header file
//#include "Afxtempl.h"
#include "resource.h"
#include "ListenSocket.h"
#include "ClientSocket.h"
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////
// CMyQQServerDlg dialogclass CMyQQServerDlg : public CDialog
{
// Construction
struct SServerMsg
{
UINT m_msgtype;
char m_msgBuff[2048];
};
struct SUserInfo
{
UINT m_infoID; //用户帐号
char m_infoNick[64]; //用户昵称
char m_infoName[64]; //用户姓名
UINT m_infoPSW; //用户密码
UINT m_infoAge; //用户年龄
UINT m_infoSex; //用户性别
UINT m_infoPicture; //用户头像
UINT m_infoIsOnLine; //用户在线状态
UINT m_infoFriendList[64];//好友名单,最多可设定64为好友
UINT m_infoBlackList[16];//黑名单,最多可设定16为黑名单

char m_infoAddr[20]; //用户IP地址
UINT m_infoPort; //用户端口
void *m_infoSocket; //用户服务器端的SOCKET指针 UINT m_infoTime; //记录用户上次保持连接的时间
};public:protected:private:
BOOL m_IsServerOn;  
CListenSocket m_listenSocket;
UINT m_iServerPort;
CString m_strServerIP;
UINT m_iTotalUser;
UINT m_iActiveUser;
UINT m_MAXID;
CList<SUserInfo,SUserInfo> m_lstAllUser;
CList<CClientSocket,CClientSocket> m_lstSocket;

};编译错误如下:
Compiling...
ClientSocket.cpp
c:\program files\microsoft visual studio\vc98\mfc\include\afxtempl.h(1064) : error C2664: 'struct __POSITION *__thiscall CList<class CClientSocket,class CClientSocket>::AddTail(class CClientSocket)' : cannot convert parameter 1 from 'class CClientSo
cket' to 'class CClientSocket'
        No copy constructor available for class 'CClientSocket'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxtempl.h(1566) : while compiling class-template member function 'void __thiscall CList<class CClientSocket,class CClientSocket>::Serialize(class CArchive &)'
ListenSocket.cpp
c:\program files\microsoft visual studio\vc98\mfc\include\afxtempl.h(1064) : error C2664: 'struct __POSITION *__thiscall CList<class CClientSocket,class CClientSocket>::AddTail(class CClientSocket)' : cannot convert parameter 1 from 'class CClientSo
cket' to 'class CClientSocket'
        No copy constructor available for class 'CClientSocket'
        c:\program files\microsoft visual studio\vc98\mfc\include\afxtempl.h(1566) : while compiling class-template member function 'void __thiscall CList<class CClientSocket,class CClientSocket>::Serialize(class CArchive &)'
MyQQServerDlg.cpp
F:\聊天室\MyQQServer\MyQQServerDlg.cpp(273) : error C2664: 'struct __POSITION *__thiscall CList<class CClientSocket,class CClientSocket>::AddTail(class CClientSocket)' : cannot convert parameter 1 from 'class CClientSocket *' to 'class CCli
entSocket'
        No constructor could take the source type, or constructor overload resolution was ambiguous
不知如何解决,请求解决

解决方案 »

  1.   

    CList <CClientSocket,CClientSocket> m_lstSocket; 
    最好改成
    CList <CClientSocket*,CClientSocket*> m_lstSocket; 
    你的CClientSocket类并不支持拷贝构造
    'class CClientSo cket' to 'class CClientSocket' 
    No copy constructor available for class 'CClientSocket' 
      

  2.   

    用CList <CClientSocket,CClientSocket> m_lstSocket; 的话,你把CClientSocket加入CList时,需要进行对象复制,但你这个类不支持这个操作。
      

  3.   

    续上这句中CList <CClientSocket,CClientSocket> m_lstSocket;的CClientSocket可能定义错误。
    在其他地方我有用到跟这个有关的程序,如下:
    void CMyQQServerDlg::OnAccept()
    {
    CClientSocket *m_clientSocket=new CClientSocket;
    m_clientSocket->SetParent(this);
    m_listenSocket.Accept(*m_clientSocket);
    m_lstSocket.AddTail(m_clientSocket); SServerMsg msg;
    msg.m_msgtype=001;
    sprintf(msg.m_msgBuff,"%s","服务器运行正常!"); m_clientSocket->Send(&msg,sizeof(SServerMsg));}
      

  4.   

    晕,那就更应该用CList <CClientSocket,CClientSocket> m_lstSocket;了,本来m_clientSocket定义的就是指针类型
      

  5.   

    从你m_lstSocket.AddTail(m_clientSocket); 的用法来看,你也希望CList存储的是指针类型
      

  6.   

    LZ   给你个建议 下个 MSDN  找到 说明 认真读下  
    如果 不这么做  劝你不要做WINDOWS 程序了