C:\WINDOWS\Desktop\GAClient\GACSocket.cpp(102) : error C2664: 'CopyMsg' : cannot convert parameter 1 from 'class CMsg' to 'class CMsg'void CGACSocket::ProcessPendingRead()
{
do
{
ReceiveMsg();
CMsg* pmsg=new CMsg;
pmsg->CopyMsg(msg);//出错
AfxBeginThread(DealData,pmsg);
//Deal();
}
while(!m_pArchiveIn->IsBufferEmpty());}void CMsg::CopyMsg(CMsg msg)
{
flag=msg.flag;
Floor=msg.Floor;
indi.IndividualInit(Floor);
for(int i=0;i<Floor*(LENGTH1+LENGTH2)+1;i++)
indi.chrom[i]=msg.indi.chrom[i];
indi.fitness=msg.indi.fitness;
for(i=0;i<Floor;i++)
indi.Kind[i]=msg.indi.Kind[i];
for(i=0;i<Floor;i++)
indi.Thick[i]=msg.indi.Thick[i];
for(i=0;i<FREQNUM;i++)
indi.value[i]=msg.indi.value[i];
m_bOnline=msg.m_bOnline;
for(i=0;i<255;i++)
m_strAction[i]=msg.m_strAction[i];
}
怎么解决?

解决方案 »

  1.   

    pmsg->CopyMsg(msg) 
    msg哪里来的变量?
      

  2.   

    class CGACSocket : public CSocket
    {
    // Attributes
    public:// Operations
    public:
    CGACSocket();
    virtual ~CGACSocket();// Overrides
    public:
    void Deal();
    void ReceiveMsg();
    void ProcessPendingRead();
    void SendMsg();
    void OnReceive(int nErrorCode);
    void Init();
    void End();
    CSocketFile* m_pFile;
    CArchive* m_pArchiveIn;
    CArchive* m_pArchiveOut;
    CMsg msg;
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CGACSocket)
    //}}AFX_VIRTUAL // Generated message map functions
    //{{AFX_MSG(CGACSocket)
    // NOTE - the ClassWizard will add and remove member functions here.
    //}}AFX_MSG// Implementation
    protected:
    };
      

  3.   

    void CMsg::CopyMsg(CMsg msg)
    定义成void CMsg::CopyMsg(CMsg* pMsg) 
    或者void CMsg::CopyMsg(CMsg& msg)
    传引用或者指针,
    你这样的定义可能问题出现在CMsg类的构造函数.
    "no copy constructor"?