CArray::InsertAt

void InsertAt(int nIndex, ARG_TYPE newElement, int nCount = 1);
  throw(CmemoryException);
void InsertAt(int nStarIndex, CArray* pNewArray);
  throw(CMemoryException);

参数:
nIndex整数值,它可以比GetUpperBound返回值大。
ARG_TYPE指定数组元素类型的模板参数。
newElement要被放置到数组中的元素。
nCount此元素应被插入的次数(缺省为1)。
nStarIndex整数索引,它可以比GetUpperBound返回值大。
pNewArray要被加入此数组的另一个包含元素的数组。

说明:
InsertAt的第一个版本在数组的特定索引上插入一个元素(或元素的多个拷贝)。在此过程中,移动(通过索引值的增加)此索引上原有的元素,并且移动所有在其后的元素。
第二个版本由另一个CArray收集插入所有元素,从nStartIndex位置开始。
SetAt函数替换一个特定数组元素,不移动任何元素。

示例:
//example for CArray::Insert
CArray ptArray;
ptArray.Add(CPoint(10,20)); //Element 0
ptArray.Add(CPoint(30,40)); //Element 1(will become element 2)
ptArray.InsertAt(1,CPoint(50,60)); //New element 1

请参阅:CArray::GetUpperBound, CArray::SetAt, CArray::RemoveAt