CObList::InsertAfter

将元素添加到此在元素后列出在指定的位置。

POSITION InsertAfter( 
   POSITION position, 
   CObject* newElement  
);

参数

  • 定位
    POSITION 值由以前的 GetNextGetPrev返回,或者 Find 成员函数调用。

  • newElement
    要添加的对象指针到此列表。

下表显示类似于 CObList::InsertAfter的其他成员函数。

成员函数

CPtrList

POSITION InsertAfter( POSITION 位置, void* newElement);

CStringList

POSITION InsertAfter( POSITION 位置, const CString& newElement);

POSITION InsertAfter( POSITION 位置, LPCTSTR newElement);

返回值

与个参数的 POSITION 值。

示例

用于列表 CAge 选件类参见 CObList::CObList

CObList list;
POSITION pos1, pos2;
list.AddHead(new CAge(21));
list.AddHead(new CAge(40)); // List now contains (40, 21). 
if ((pos1 = list.GetHeadPosition()) != NULL)
{
    pos2 = list.InsertAfter(pos1, new CAge(65));
}
#ifdef _DEBUG
   afxDump.SetDepth(1);
   afxDump << _T("InsertAfter example: ") << &list << _T("\n");
#endif

从此过程的结果如下:

InsertAfter example: A CObList with 3 elements

a CAge at $4A44 40

a CAge at $4A64 65

a CAge at $4968 21

要求

Header: afxcoll.h

请参见

参考

CObList Class

层次结构图

CObList::Find

CObList::InsertBefore