Freigeben über


CObList::RemoveAll

Removes all the elements from this list and frees the associated CObList memory.

void RemoveAll( );

Remarks

No error is generated if the list is already empty.

When you remove elements from a CObList, you remove the object pointers from the list. It is your responsibility to delete the objects themselves.

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

Class

Member Function

CPtrList

void RemoveAll( );

CStringList

void RemoveAll( );

Example

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

CObList list;
CAge* pa1;
CAge* pa2;
ASSERT(list.IsEmpty()); // Yes it is.
list.AddHead(pa1 = new CAge(21));
list.AddHead(pa2 = new CAge(40)); // List now contains (40, 21).
ASSERT(!list.IsEmpty()); // No it isn't.
list.RemoveAll(); // CAges aren't destroyed.
ASSERT(list.IsEmpty()); // Yes it is.
delete pa1;     // Now delete the CAge objects.
delete pa2;      

Requirements

Header: afxcoll.h

See Also

Reference

CObList Class

Hierarchy Chart

Other Resources

CObList Members