void SetAtGrow( int nIndex, CObject* newElement )
throw( CMemoryException );
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.
Sets the array element at the specified index. The array grows automatically if necessary (that is, the upper bound is adjusted to accommodate the new element).
CObArray array;
array.Add( new CAge( 21 ) ); // Element 0
array.Add( new CAge( 40 ) ); // Element 1
array.SetAtGrow( 3, new CAge( 65 ) ); // Element 2 deliberately
// skipped
#ifdef _DEBUG
afxDump.SetDepth( 1 );
afxDump << "SetAtGrow example: " << &array << "\\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
CObArray::GetAt, CObArray::SetAt, CObArray::ElementAt, CObArray::operator []