POSITION pos = m_stringList[m_nDay].GetHeadPosition();//这句话到底表示什么意思,我看了msdn还是不懂,下一句也一样
strOld = m_stringList[m_nDay].GetNext(pos);
望高手指点

解决方案 »

  1.   

    获得链表头的POSITION值,与下句结合,常用来遍历或查找链表中的项
      

  2.   

    GetHeadPosition 返回的是链表头元素的位置
    GetNext(pos) 返回的是连标中pos所指的元素并将pos指向下一个元素
    调用GetNext后pos的值就改变了
    可以用一下循环遍历链表所有元素for (POSITION pos = list.GetHeadPosition(); pos != NULL;)
    {
        (yourclass*) yc = (yourclass)GetNext(pos);
    }
      

  3.   

    更正:
    for (POSITION pos = list.GetHeadPosition(); pos != NULL;)
    {
        (yourclass*) yc = (yourclass*)GetNext(pos);
    }
      

  4.   

    我一般这么用CList<...> list;//或CObList...for(POSITION pos = list.GetHeadPosition();pos;list.GetNext(pos))
    {
        yourObject = (yourObjectType )list.GetAt(pos);
    }
      

  5.   

    这属于对象链表指针使用。CObList类是其基类,用来管理同一类的多个对象(实例).  m_stringList[m_nDay]是一个链表对象;POSITION pos = m_stringList[m_nDay].GetHeadPosition();
    //得到m_stringList[m_nDay] 链表指针的首位置.
    strOld = m_stringList[m_nDay].GetNext(pos);
    //得到该指针位置上的对象,并使得m_stringList[m_nDay]链表指针指向下一位.
    重复上述过程,可遍历该指针所指的所有对象,直到POS为空!
      

  6.   

    MS是这样定义的// abstract iteration position
    struct __POSITION {};
    typedef __POSITION* POSITION;