Condividi tramite


CObArray::Append

Call this member function to add the contents of another array to the end of the given array.

INT_PTR Append(
   const CObArray& src 
);

Parameters

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

Return Value

The index of the first appended element.

Remarks

The arrays must be of the same type.

If necessary, Append may allocate extra memory to accommodate the elements appended to the array.

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

Class

Member Function

CByteArray

INT_PTR Append( const CByteArray& src );

CDWordArray

INT_PTR Append( const CDWordArray& src );

CPtrArray

INT_PTR Append( const CPtrArray& src );

CStringArray

INT_PTR Append( const CStringArray& src );

CUIntArray

INT_PTR Append( const CUIntArray& src );

CWordArray

INT_PTR Append( 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));

// Add elements to the first array and also append the second array.
myArray1.Add(new CAge(3));
myArray1.Append(myArray2);

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

Requirements

Header: afxcoll.h

See Also

Reference

CObArray Class

Hierarchy Chart

CObArray::Copy

Other Resources

CObArray Members