SetAt
Adds a reference to the passed object newElement, at the indicated index nIndex.
BOOL SetAt( 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_SetAt_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); } //get the middle item to change its value. int nMid = nTotal/2; if ( nMid < nTotal ) { PERSON* pp = new PERSON; pp->nID = 12345; if ( !arp.SetAt(nMid, *pp) ) printf("Fail to set the %dth item.", nMid); } for ( ii = 0; ii < nTotal; ii++ ) printf("Person %d's ID is : %d\n", ii + 1, arp.GetAt(ii).nID); }
Array::GetAt, Array::SetAtGrow
Array.h