CAtlArray::Add

Call this method to add an element to the array object.

size_t Add(
   INARGTYPE element 
);
size_t Add( );

Parameters

  • element
    The element to be added to the array.

Return Value

Returns the index of the added element.

Remarks

The new element is added to the end of the array. If no element is provided, an empty element is added; that is, the array is increased in size as though a real element has been added. If the operation fails, AtlThrow is called with the argument E_OUTOFMEMORY.

Example

// Declare an array of integers
CAtlArray<int> iArray;

iArray.Add(1);   // element 0
iArray.Add(2);   // element 1
iArray.Add();    // element 2

ATLASSERT(iArray.GetCount() == 3);   

Requirements

Header: atlcoll.h

See Also

Reference

CAtlArray Class

CAtlArray::InsertAt

Other Resources

CAtlArray Members