CObList::AddHead
POSITION AddHead( CObject* newElement );
throw( CMemoryException );
void AddHead( CObList* pNewList );
throw( CMemoryException );
返回值:
第一种版本返回新插入元素的POSITION值。
参数:
newElement
新插入到该列表的CObject指针。
pNewList
另一个CObList列表的指针。pNewList中的元素将被添加到列表中。
说明:
在列表头添加一个或一列新元素。在操作前该列表可以为空。
示例:
CObList list;
list.AddHead( new CAge( 21 ) ); // 21 is now at head.
list.AddHead( new CAge( 40 ) ); // 40 replaces 21 at head.
#ifdef _DEBUG
afxDump.SetDepth( 1 );
afxDump << "AddHead example: " << &list << "\n";
#endif
该程序的结果如下:
AddHead example: A CObList with 2 elements
a CAge at $44A8 40
a CAge at $442A 21
请参阅:
CObList::GetHead
,
CObList::RemoveHead