CObList::CObList

构造空 CObject 指针列表。

CObList( 
   INT_PTR nBlockSize = 10  
);

参数

  • nBlockSize
    扩展的列表内存分配粒度。

备注

在列表增大,内存 nBlockSize 项单元中。 如果内存分配失败,CMemoryException 将引发。

下表显示类似于 CObList::CObList的其他成员函数。

成员函数

CPtrList

CPtrList( INT_PTR nBlockSize = 10 );

CStringList

CStringList( INT_PTR nBlockSize = 10 );

示例

下面列出 CObject派生类用于任何集合示例的 CAge :

// Simple CObject-derived class for CObList and other examples
class CAge : public CObject
{
    DECLARE_SERIAL( CAge )
private:
    int   m_years;
public:
    CAge() { m_years = 0; }
    CAge(int age) { m_years = age; }
    CAge(const CAge& a) { m_years = a.m_years; } // Copy constructor
    void Serialize(CArchive& ar);
    void AssertValid() const;
    const CAge& operator=(const CAge& a)
    {
        m_years = a.m_years; return *this;
    }
    BOOL operator==(CAge a)
    {
        return m_years == a.m_years;
    }
#ifdef _DEBUG
    void Dump(CDumpContext& dc) const
    {
        CObject::Dump(dc);
        dc << m_years; 
    }
#endif
};

下面 CObList 构造函数的用法示例:

CObList list(20);  // List on the stack with blocksize = 20.

CObList* plist = new CObList; // List on the heap with default  
                              // blocksize.         

要求

Header: afxcoll.h

请参见

参考

CObList Class

层次结构图