学了VC四五年了,但至今对链表问题的认识还很模糊。更不知什么时候需要建立链表和怎么去建立链表。望高手指点,最好结合实例说明。谢谢!!

解决方案 »

  1.   

    现在的链表之类都在STL,boost之类的库中了,我一般读结构相同,值不同的一些结构体之类的用链表
      

  2.   

    呵呵,是该好好向各位请教!!!
    class CClientInfo : public CObject  
    {
    DECLARE_SERIAL(CClientInfo)
    public:
    HWND m_hWnd;//窗口句柄
    sockaddr_in m_Cmddst;
    sockaddr_in m_AVdst;
    BOOL bMain;
    short UID;
    int m_uDataRcv;
    int m_iZeroCount;
    int m_ChatNo;
    CString m_szIP;
    CClientInfo();
    virtual ~CClientInfo();};
    typedef CTypedPtrList<CObList, CClientInfo*> CClientInfoList;
    typedef CTypedPtrList<CObList, CClientInfo*> CClientInfoList;谁能解释一下为什么要这样写?怎么调用它?
      

  3.   

    是不是用CClientInfoList类来封装CClientInfo类的信息?然后才可能在其它类中进行调用它?如:
    CClientInfoList m_ClientInfoList;
        POSITION pos;
    if (m_ClientInfoList.GetCount()!=0)
    {
    for( pos = m_ClientInfoList.GetHeadPosition(); pos != NULL; )
    {
              CClientInfo *pClientInfo=m_ClientInfoList.GetAt(pos);
     .................
    m_ClientInfoList.GetNext(pos);
    }// end of for                                                
    }
    但是我看到有些代码直接写成这样CPtrList m_connectionList;然后这样调用
    for(POSITION pos = m_connectionList.GetHeadPosition ();pos!=NULL;)
    {
    CClientSocket* pSocket = (CClientSocket*)m_connectionList.GetNext (pos);
    ..............
    }
    typedef CTypedPtrList <CObList, CClientInfo*> CClientInfoList与CPtrList m_connectionList写有什么作用?谢谢!!
      

  4.   

    啊?
    就是封装成CClientInfo的容器对象么。是一个链表
      

  5.   

    typedef CTypedPtrList <CObList, CClientInfo*> CClientInfoList
    是个继承的模板容器吧