CObArray::Add

int Add( CObject* newElement );
  throw( CMemoryException );

返回值:返回新增元素的索引。

参数:
newElement新增到该数组的CObject指针。

说明:
在数组尾新增一个元素,并使数组增加1。如果SetSize用到的nGrowBy值超过1,那么将分配额外的内存。不过,数组上界将只增加1。
下表列出了类似于CObArray::Add函数的其它成员函数。
成员函数
CByteArrayint Add( BYTE newElement )
  throw( CMemoryException )
CDWordArrayint Add( DWORD newElement )
  throw( CMemoryException )
CPtrArrayint Add( void* newElement )
  throw( CMemoryException )
CStringArrayint Add( LPCTSTR newElement )
  throw( CMemoryException )
CUIntArrayint Add( UINT newElement )
  throw( CMemoryException )
CWordArrayint Add( WORD newElement )
  throw( CMemoryException )

示例:
请参阅CObList::CObList,了解所有收集示例中使用的CAge类。
// example for CObArray::Add
CObArray array;
array.Add( new CAge( 21 ) ); // Element 0
array.Add( new CAge( 40 ) ); // Element 1
#ifdef _DEBUG
   afxDump.SetDepth( 1 );
   afxDump << "Add example: " << &array << "\n";
#endif
该程序的结果如下:
Add example: A CObArray with 2 elements
    [0] = a CAge at $442A 21
    [1] = a CAge at $4468 40

请参阅:
CObArray::SetAt, CObArray::SetAtGrow, CObArray::InsertAt, CObArray::operator []