Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic


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

POSITION InsertAfter( 
   POSITION position, 
   CObject* newElement  

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


The object pointer to be added to this list.

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


Member Function


POSITION InsertAfter( POSITION position , void* newElement );


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

POSITION InsertAfter( POSITION position , LPCTSTR newElement );

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

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 << _T("InsertAfter example: ") << &list << _T("\n");

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

Header: afxcoll.h

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.