Export (0) Print
Expand All


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.

Class 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.SetDepth( 1 );
   afxDump << "InsertAfter example: " << &list << "\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

Community Additions

© 2014 Microsoft