CArray::GetAt

Returns the array element at the specified index.

TYPE& GetAt( 
   INT_PTR nIndex  
);
const TYPE& GetAt( 
   INT_PTR nIndex
) const;

Parameters

  • TYPE
    Template parameter specifying the type of the array elements.

  • nIndex
    An integer index that is greater than or equal to 0 and less than or equal to the value returned by GetUpperBound.

Return Value

The array element currently at this index.

Remarks

Passing a negative value or a value greater than the value returned by GetUpperBound will result in a failed assertion.

Example

CArray<CPoint,CPoint> myArray;
CPoint pt;

// Add elements to the array.
for (int i = 0; i < 10; i++)
   myArray.Add(CPoint(i, 2 * i));

// Modify all the points in the array.
for (int i = 0; i <= myArray.GetUpperBound(); i++)
{
   pt = myArray.GetAt(i);
   pt.x = 0;
   myArray.SetAt(i, pt);
}

Requirements

Header: afxtempl.h

See Also

Reference

CArray Class

Hierarchy Chart

CArray::SetAt

CArray::operator []

Other Resources

CArray Members