网站首页  词典首页

请输入您要查询的计算机术语:

 

术语 CObArray::SetAtGrow
释义 CObArray::SetAtGrow

void SetAtGrow( int nIndex, CObject* newElement );
  throw( CMemoryException );

参数:
nIndex大于或等于0的整数索引值。
newElement新增到该数组的对象指针,该值允许为空值。

说明:
在指定索引处设定数组元素。如果必要,那么数组将自动增长(也就是说,数组上界将自动调节,以容纳新的元素)。
下表列出了类似于CObArray::SetAtGrow函数的其它成员函数。
成员函数
CByteArrayvoid SetAtGrow( int nIndex, BYTE newElement );
  throw( CMemoryException );
CDWordArrayvoid SetAtGrow( int nIndex, DWORD newElement );
  throw( CMemoryException );
CPtrArrayvoid SetAtGrow( int nIndex, void* newElement );
  throw( CMemoryException );
CStringArrayvoid SetAtGrow( int nIndex, LPCTSTR newElement );
  throw( CMemoryException );
CUIntArrayvoid SetAtGrow( int nIndex, UINT newElement );
  throw( CMemoryException );
CWordArrayvoid SetAtGrow( int nIndex, WORD newElement );
  throw( CMemoryException );

示例:
请参阅CObList::CObList,了解所有收集示例中使用的CAge类。
// example for CObArray::SetAtGrow
CObArray array;
array.Add( new CAge( 21 ) ); // Element 0
array.Add( new CAge( 40 ) ); // Element 1
array.SetAtGrow( 3, new CAge( 65 ) ); // Element 2 deliberately// skipped
#ifdef _DEBUG
   afxDump.SetDepth( 1 );
   afxDump << "SetAtGrow example: " << &array << "\";
#endif
该程序的结果如下:
SetAtGrow example: A CObArray with 4 elements
[0] = a CAge at $47C0 21
[1] = a CAge at $4800 40
[2] = NULL
[3] = a CAge at $4840 65

请参阅:
CObArray::GetAt, CObArray::SetAt, CObArray::ElementAt, CObArray::operator []
随便看

 

MFC类库中文详解手册包含4274条MFC类库参考词条,基本涵盖了Microsoft基本类库中的类、全局函数、全局变量和宏的内容,是计算机编程的有利工具。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 12:32:08