Compartilhar via


CObList::InsertAfter

Adds an element to this list after the element at the specified position.

POSITION InsertAfter(
   POSITION position,
   CObject* newElement 
);

Parameters

  • position
    A POSITION value returned by a previous GetNext, GetPrev, or Find member function call.

  • newElement
    The object pointer to be added to this list.

The following table shows other member functions that are similar to CObList::InsertAfter.

Class

Member Function

CPtrList

POSITION InsertAfter( POSITION position, void* newElement );

CStringList

POSITION InsertAfter( POSITION position, const CString& newElement );

POSITION InsertAfter( POSITION position, LPCTSTR newElement );

Return Value

A POSITION value which is the same as the position parameter.

Example

See CObList::CObList for a listing of the CAge class.

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

The results from this program are as follows:

InsertAfter example: A CObList with 3 elements

a CAge at $4A44 40

a CAge at $4A64 65

a CAge at $4968 21

Requirements

Header: afxcoll.h

See Also

Reference

CObList Class

Hierarchy Chart

CObList::Find

CObList::InsertBefore

Other Resources

CObList Members