CObArray::RemoveAll

Removes all the pointers from this array but does not actually delete the CObject objects.

void RemoveAll( );

Remarks

If the array is already empty, the function still works.

The RemoveAll function frees all memory used for pointer storage.

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

Class

Member Function

CByteArray

void RemoveAll( );

CDWordArray

void RemoveAll( );

CPtrArray

void RemoveAll( );

CStringArray

void RemoveAll( );

CUIntArray

void RemoveAll( );

CWordArray

void RemoveAll( );

Example

See CObList::CObList for a listing of the CAge class used in all collection examples.

CObArray arr;
CAge* pa1;
CAge* pa2;

arr.Add(pa1 = new CAge(21)); // Element 0
arr.Add(pa2 = new CAge(40)); // Element 1
ASSERT(arr.GetSize() == 2);
arr.RemoveAll(); // Pointers removed but objects not deleted.
ASSERT(arr.GetSize() == 0);
delete pa1;
delete pa2;  // Cleans up memory.      

Requirements

Header: afxcoll.h

See Also

Reference

CObArray Class

Hierarchy Chart

Other Resources

CObArray Members