CObArray::GetAt
Returns the array element at the specified index.
CObject* GetAt(
INT_PTR nIndex
) const;
Parameters
- 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 CObject pointer element currently at this index.
Remarks
Note
Passing a negative value or a value greater than the value returned by GetUpperBound will result in a failed assertion.
The following table shows other member functions that are similar to CObArray::GetAt.
Class |
Member Function |
---|---|
BYTE GetAt( INT_PTR nIndex ) const; |
|
DWORD GetAt( INT_PTR nIndex ) const; |
|
void* GetAt( INT_PTR nIndex ) const; |
|
CString GetAt( INT_PTR nIndex ) const; |
|
UINT GetAt( INT_PTR nIndex ) const; |
|
WORD GetAt( INT_PTR nIndex ) const; |
Example
See CObList::CObList for a listing of the CAge class used in all collection examples.
CObArray arr;
arr.Add(new CAge(21)); // Element 0
arr.Add(new CAge(40)); // Element 1
ASSERT(*(CAge*) arr.GetAt(0) == CAge(21));
Requirements
Header: afxcoll.h