CObArray::SetAtGrow
Sets the array element at the specified index.
void SetAtGrow(
INT_PTR nIndex,
CObject* newElement
);
Параметры
nIndex
An integer index that is greater than or equal to 0.newElement
The object pointer to be added to this array. A NULL value is allowed.
Заметки
The array grows automatically if necessary (that is, the upper bound is adjusted to accommodate the new element).
The following table shows other member functions that are similar to CObArray::SetAtGrow.
Class |
Member Function |
---|---|
void SetAtGrow( INT_PTR nIndex, BYTE newElement ); throw( CMemoryException* ); |
|
void SetAtGrow( INT_PTR nIndex, DWORD newElement ); throw( CMemoryException* ); |
|
void SetAtGrow( INT_PTR nIndex, void* newElement ); throw( CMemoryException* ); |
|
void SetAtGrow( INT_PTR nIndex, LPCTSTR newElement ); throw( CMemoryException* ); |
|
void SetAtGrow( INT_PTR nIndex, UINT newElement ); throw( CMemoryException* ); |
|
void SetAtGrow( INT_PTR nIndex, WORD newElement ); throw( CMemoryException* ); |
Пример
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
arr.SetAtGrow(3, new CAge(65)); // Element 2 deliberately
// skipped.
#ifdef _DEBUG
afxDump.SetDepth(1);
afxDump << _T("SetAtGrow example: ") << &arr << _T("\n");
#endif
The results from this program are as follows:
SetAtGrow example: A CObArray with 4 elements
[0] = a CAge at $47C0 21
[1] = a CAge at $4800 40
[2] = NULL
[3] = a CAge at $4840 65
Требования
Header: afxcoll.h