CAtlArray::GetAt

Call this method to retrieves a single element from the array object.

const E& GetAt(
   size_t iElement 
) const throw( );
E& GetAt(
   size_t iElement 
) throw( );

Parameters

  • iElement
    The index value of the array element to return.

Return Value

Returns a reference to the required array element.

Remarks

In debug builds, an ATLASSERT will be raised if iElement exceeds the number of elements in the array. In release builds, an invalid argument may lead to unpredictable behavior.

Example

// Declare an array of integers

CAtlArray<int> iMyArray;
int element;

// Add ten elements to the array
for (int i = 0; i < 10; i++)
{
   iMyArray.Add(i);
}

// Use GetAt and SetAt to modify
// every element in the array

for (size_t i = 0; i < iMyArray.GetCount(); i++)
{
   element = iMyArray.GetAt(i);
   element *= 10;
   iMyArray.SetAt(i, element);
}   

Requirements

Header: atlcoll.h

See Also

Reference

CAtlArray Class

CAtlArray::SetAt

Other Resources

CAtlArray Members