CItem是CObject的派生类发送部分:
CItem pItem = new CItem;
pItem->Name = "aaa";
pItem->Age =22;*(pSocket->m_pArOut)<<pItem;
pSocket->m_pArOut->Flush();接收部分
CItem* pItem = new CItem;
*(pSocket->m_pArIn)>>pItem;//此处编译报错
//错误为binary '>>' : no operator defined which takes a right-hand operand of type 'class CItem *' (or there is no acceptable conversion)怎么解决啊?

解决方案 »

  1.   

    为CItem重载>>和<<操作符。
      

  2.   

    CItem是CObject的派生类,可能是你没有DECLARE_SERIAL/IMPLEMENT_SEARIAL吧
      

  3.   

    不是啊,是类型不匹配——没看到提示“takes a right-hand operand of type 'class CItem *'”,你>>操作的右操作数竟然是个指针哎。
      

  4.   

    Oh,
    *(pSocket->m_pArOut)<<(*pItem);
    试试
      

  5.   

    char buf[1024]="";
    *(pSocket->m_pArIn)>>buf;
    pItem=(CItem*)buf;
      

  6.   

    添加了DECLARE_SERIAL/IMPLEMENT_SEARIAL后编译通过了,可发送正常,接收到的却是空值?
      

  7.   

    发送部分:
    CItem pItem = new CItem;
    pItem->Name = "aaa";
    pItem->Age =22;*(pSocket->m_pArOut)<<pItem;接收部分
    CItem* pItem = new CItem;
    *(pSocket->m_pArIn)>>pItem;//此处编译报错===================================
    ??????楼主,你......