Inserts one element at a specified index in the array.
BOOL InsertAt( int nIndex, _TemplType newElement )
Returns a boolean indicating success or failure of the requested operation
#include <Array.h> struct PERSON { int nID; }; void Array_InsertAt_ex1() { Array<PERSON&> arp(true); //is owner for ( int ii = 0; ii < 4; ii++ ) { PERSON* tp = new PERSON; tp->nID = ii + 1; arp.Add(*tp); } for ( ii = 0; ii < arp.GetSize(); ii++ ) printf("Person %d's ID is : %d\n", ii + 1, arp.GetAt(ii).nID); PERSON* pp = new PERSON; pp->nID = 12345; if ( !arp.InsertAt(0, *pp) ) out_str("Fail to insert at the first item."); for ( ii = 0; ii < arp.GetSize(); ii++ ) printf("Person %d's ID is : %d\n", ii + 1, arp.GetAt(ii).nID); }
Array.h