Share via


CObList::CObList

空の CObject のポインターのリストを構築します。

CObList(
   INT_PTR nBlockSize = 10 
);

パラメーター

  • nBlockSize
    リストを拡張するためのメモリ割り当ての単位。

解説

リストが増大したときに、メモリが nBlockSize エントリの単位で割り当てられます。メモリ割り当てに失敗した場合、CMemoryException がスローされます。

次の表は CObList::CObListに似ている他のメンバー関数を示します。

Class

メンバー関数

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 クラス

階層図