Export (0) Print
Expand All

CList::GetHead

Gets the head element (or a reference to the head element) of this list.

const TYPE& GetHead( ) const; 
TYPE& GetHead( );

TYPE

Template parameter specifying the type of object in the list.

If the list is const, GetHead returns a copy of the element at the head of the list. This allows the function to be used only on the right side of an assignment statement and protects the list from modification.

If the list is not const, GetHead returns a reference to the element at the head of the list. This allows the function to be used on either side of an assignment statement and thus allows the list entries to be modified.

You must ensure that the list is not empty before calling GetHead. 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.

// Define myList.
CList<CString,CString&> myList;

// Add an element to the front of the list.
myList.AddHead(CString(_T("ABC")));

// Verify the element was added to the front of the list.
ASSERT(CString(_T("ABC")) == myList.GetHead());      

Header: afxtempl.h

Show:
© 2014 Microsoft