Partager via


CTypedPtrList::GetNext

Gets the list element identified by rPosition, then sets rPosition to the POSITION value of the next entry in the list.

TYPE& GetNext( 
   POSITION& rPosition  
); 
TYPE GetNext( 
   POSITION& rPosition  
) const;

Parameters

  • TYPE
    Template parameter specifying the type of elements contained in this list.

  • rPosition
    A reference to a POSITION value returned by a previous GetNext, GetHeadPosition, or other member function call.

Return Value

If the list is accessed through a pointer to a const CTypedPtrList, then GetNext returns a pointer of the type specified by the template parameter TYPE. This allows the function to be used only on the right side of an assignment statement and thus protects the list from modification.

If the list is accessed directly or through a pointer to a CTypedPtrList, then GetNext returns a reference to a pointer of the type specified by the template parameter TYPE. This allows the function to be used on either side of an assignment statement and thus allows the list entries to be modified.

Remarks

You can use GetNext in a forward iteration loop if you establish the initial position with a call to GetHeadPosition or CPtrList::Find.

You must ensure that your POSITION value represents a valid position in the list. If it is invalid, then the Debug version of the Microsoft Foundation Class Library asserts.

If the retrieved element is the last in the list, then the new value of rPosition is set to NULL.

It is possible to remove an element during an iteration. See the example for CObList::RemoveAt.

Requirements

Header: afxtempl.h

See Also

Reference

CTypedPtrList Class

Hierarchy Chart

CObList::Find

CObList::GetHeadPosition

CObList::GetTailPosition

CTypedPtrList::GetPrev

CTypedPtrList::GetHead

CTypedPtrList::GetTail