CObList::InsertAfter

Syntax

POSITION InsertAfter( POSITION position, CObject* newElement );
throw ( CMemoryException );

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.

Remarks

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

Example

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";

#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

See Also

CObList::Find, CObList::InsertBefore