CObArray::SetAtGrow

void SetAtGrow( int nIndex, CObject* newElement );
  throw( CMemoryException );

参数:
nIndex大于或等于0的整数索引值。
newElement新增到该数组的对象指针,该值允许为空值。

说明:
在指定索引处设定数组元素。如果必要,那么数组将自动增长(也就是说,数组上界将自动调节,以容纳新的元素)。
下表列出了类似于CObArray::SetAtGrow函数的其它成员函数。
成员函数
CByteArrayvoid SetAtGrow( int nIndex, BYTE newElement );
  throw( CMemoryException );
CDWordArrayvoid SetAtGrow( int nIndex, DWORD newElement );
  throw( CMemoryException );
CPtrArrayvoid SetAtGrow( int nIndex, void* newElement );
  throw( CMemoryException );
CStringArrayvoid SetAtGrow( int nIndex, LPCTSTR newElement );
  throw( CMemoryException );
CUIntArrayvoid SetAtGrow( int nIndex, UINT newElement );
  throw( CMemoryException );
CWordArrayvoid SetAtGrow( int nIndex, WORD newElement );
  throw( CMemoryException );

示例:
请参阅CObList::CObList,了解所有收集示例中使用的CAge类。
// example for CObArray::SetAtGrow
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
该程序的结果如下:
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 []