Partager via


CObArray::Copy

Call this member function to overwrite the elements of the given array with the elements of another array of the same type.

void Copy( 
   const CObArray& src  
);

Parameters

  • src
    Source of the elements to be copied to the array.

Remarks

Copy does not free memory; however, if necessary, Copy may allocate extra memory to accommodate the elements copied to the array.

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

Class

Member Function

CByteArray

void Copy( const CByteArray& src );

CDWordArray

void Copy( const CDWordArray& src );

CPtrArray

void Copy( const CPtrArray& src );

CStringArray

void Copy( const CStringArray& src );

CUIntArray

void Copy( const CUIntArray& src );

CWordArray

void Copy( const CWordArray& src );

Example

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

CObArray myArray1, myArray2;

// Add elements to the second array.
myArray2.Add(new CAge(21));
myArray2.Add(new CAge(42));

// Copy the elements from the second array to the first.
myArray1.Copy(myArray2);

#ifdef _DEBUG
   afxDump.SetDepth(1);
   afxDump << "myArray1: " << &myArray1 << "\n";
   afxDump << "myArray2: " << &myArray2 << "\n";
#endif      

Requirements

Header: afxcoll.h

See Also

Reference

CObArray Class

Hierarchy Chart

CObArray::Append