Partager via


CAtlArray::Append

Call this method to add the contents of one array to the end of another.

size_t Append( 
   const CAtlArray< E, ETraits >& aSrc  
);

Parameters

  • aSrc
    The array to append.

Return Value

Returns the index of the first appended element.

Remarks

The elements in the supplied array are added to the end of the existing array. If necessary, memory will be allocated to accommodate the new elements.

The arrays must be of the same type, and it is not possible to append an array to itself.

In debug builds, an ATLASSERT will be raised if the CAtlArray argument is not a valid array or if aSrc refers to the same object. In release builds, invalid arguments may lead to unpredictable behavior.

Example

// Declare two integer arrays
CAtlArray<int> iArray1,iArray2;

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

iArray2.Add(3);   // element 0
iArray2.Add(4);   // element 1 

// Append iArray2 to iArray1
iArray1.Append(iArray2);

ATLASSERT(iArray1.GetCount() == 4);   

Requirements

Header: atlcoll.h

See Also

Reference

CAtlArray Class

CAtlArray::InsertArrayAt