Share via


CList::InsertAfter

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

POSITION InsertAfter( 
   POSITION position, 
   ARG_TYPE newElement  
);

Parameters

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

  • ARG_TYPE
    Template parameter specifying the type of the list element.

  • newElement
    The element to be added to this list.

Return Value

A POSITION value that can be used for iteration or list element retrieval.

Example

// Define myList.
CList<CString,CString&> myList;

// Add three elements to the list.
POSITION pos = myList.AddHead(CString(_T("XYZ")));
pos = myList.InsertAfter(pos, CString(_T("ABC")));
pos = myList.InsertAfter(pos, CString(_T("123")));

// Verify the tail element is what's expected.
ASSERT(CString(_T("123")) == myList.GetTail());   

Requirements

Header: afxtempl.h

See Also

Reference

CList Class

Hierarchy Chart

CList::Find

CList::InsertBefore