SetAtGrow
Adds a reference to the passed object newElement, at the indicated index nIndex. Enlarges the array if needed.
BOOL SetAtGrow( int nIndex, _TemplType newElement )
Returns a boolean indicating success or failure of the requested operation
EX1
#include <Array.h> struct PERSON { int nID; }; void Array_SetAtGrow_ex1() { Array<PERSON&> arp(true); int nTotal = 5; for ( int ii = 0; ii < nTotal; ii++ ) { PERSON* pp = new PERSON; //assume memory allocated successfully. pp->nID = ii + 1; arp.Add(*pp); } PERSON* p = new PERSON; p->nID = 999; arp.SetAtGrow(10, *p);//after set, the array's size will be 11 int nSize = arp.GetSize(); for ( ii = 0; ii < nSize; ii++ ) { PERSON& pm = arp.GetAt(ii); if ( pm ) //some item maybe invalid, so need to check before use it. { printf("PERSON %d's ID is : %d\n", ii + 1, pm.nID); } } }
Array::SetAt
Array.h