CObList::RemoveHead

Removes the element from the head of the list and returns a pointer to it.

CObject* RemoveHead( );

Return Value

The CObject pointer previously at the head of the list.

Remarks

You must ensure that the list is not empty before calling RemoveHead. If the list is empty, then the Debug version of the Microsoft Foundation Class Library asserts. Use IsEmpty to verify that the list contains elements.

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

Class

Member Function

CPtrList

void* RemoveHead( );

CStringList

CString RemoveHead( );

Example

See CObList::CObList for a listing of the CAge class.

CObList list;
CAge* pa1;
CAge* pa2;

list.AddHead(pa1 = new CAge(21));
list.AddHead(pa2 = new CAge(40)); // List now contains (40, 21).
ASSERT(*(CAge*) list.RemoveHead() == CAge(40));  // Old head
ASSERT(*(CAge*) list.GetHead() == CAge(21));  // New head 
delete pa1;
delete pa2;      

Requirements

Header: afxcoll.h

See Also

Reference

CObList Class

Hierarchy Chart

CObList::GetHead

CObList::AddHead

Other Resources

CObList Members