Compartir a través de


CAtlArray::Copy

Call this method to copy the elements of one array to another.

void Copy( 
   const CAtlArray< E, ETraits >& aSrc  
);

Parameters

  • aSrc
    The source of the elements to copy to an array.

Remarks

Call this method to overwrite elements of one array with the elements of another array. If necessary, memory will be allocated to accommodate the new elements. It is not possible to copy elements of an array to itself.

If the existing contents of the array are to be retained, use CAtlArray::Append instead.

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

Note

CAtlArray::Copy does not support arrays consisting of elements created with the CAutoPtr class.

Example

CAtlArray<int> iArrayS, iArrayT;

iArrayS.Add(1);
iArrayS.Add(2);

iArrayT.Add(3);
iArrayT.Add(4);

iArrayT.Copy(iArrayS);

ATLASSERT(iArrayT.GetCount() == 2);
ATLASSERT(iArrayT[0] == 1);
ATLASSERT(iArrayT[1] == 2);   

Requirements

Header: atlcoll.h

See Also

Reference

CAtlArray Class