MFC 数组类
CByteArray:
CDWordArray:
CPtrArray:
CUIntArray:
CWordArray:
CStringArray:
常用成员函数
1.int Add
( ARG_TYPE newElement ); throw
( CMemoryException );
2.TYPE& ElementAt
( int nIndex );
3.void FreeExtra
( );
4.TYPE GetAt
( int nIndex
) const
5.int GetSize
( ) const;
6.int GetUpperBound
( ) const;
7.(1)void InsertAt
( int nIndex, ARG_TYPE newElement, int nCount = 1 );
throw
( CMemoryException );
(2)void InsertAt
( int nStartIndex, CArray* pNewArray );
throw
( CMemoryException );
8.void RemoveAll
( );
9.void SetAt
( int nIndex, ARG_TYPE newElement );
10.void SetAtGrow
( int nIndex, ARG_TYPE newElement ); throw
( CMemoryException );
11.void SetSize
( int nNewSize, int nGrowBy = -1 ); throw
( CMemoryException );
例:
CStringArray m_strArray
m_strArray.SetSize(5,5);
m_strArray[0] = "111111111111";
m_strArray[2] = "333333333333";
m_strArray[4] = "555555555555";
增加元素
int m_nIndex = 0;
CString m_strValue = "Default";
int m_nRadio = 0;
if (m_nRadio == 0)
m_strArray.SetAtGrow(m_nIndex, m_strValue);
else if (m_nRadio == 1)
m_strArray.Add(m_strValue);
else
m_strArray.InsertAt(m_nIndex, m_strValue, 1);
删除
int m_nIndex= 0;
m_strArray.RemoveAt(m_nIndex);
MFC 的链表类
模板类 Clist CTypedPtrList