int Add( CObject* newElement )
throw( CMemoryException );
newElement
The CObject pointer to be added to this array.
Adds a new element to the end of an array, growing the array by 1. If SetSize has been used with an nGrowBy value greater than 1, then extra memory may be allocated. However the upper bound will increase by only 1.
The index of the added element.
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
The results from this program are as follows:
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 []