Share via


CArray::Add

Adds a new element to the end of an array, growing the array by 1.

INT_PTR Add( 
   ARG_TYPE newElement  
);

Parameters

  • ARG_TYPE
    Template parameter specifying the type of arguments referencing elements in this array.

  • newElement
    The element to be added to this array.

Return Value

The index of the added element.

Remarks

If SetSize has been used with an nGrowBy value greater than 1, then extra memory may be allocated. However, the upper bound will increase by only 1.

Example

// example for CArray::Add
CArray<CPoint,CPoint> ptArray;

CPoint pt(10,20);
ptArray.Add(pt);             // Element 0
ptArray.Add(CPoint(30,40));  // Element 1

Requirements

Header: afxtempl.h

See Also

Reference

CArray Class

Hierarchy Chart

CArray::SetAt

CArray::SetAtGrow

CArray::InsertAt

CArray::operator []

Other Resources

CArray Members