Share via


CObList::CObList

Constructs an empty CObject pointer list.

CObList(
   INT_PTR nBlockSize = 10 
);

Parameters

  • nBlockSize
    The memory-allocation granularity for extending the list.

Remarks

As the list grows, memory is allocated in units of nBlockSize entries. If a memory allocation fails, a CMemoryException is thrown.

The following table shows other member functions that are similar to CObList::CObList.

Class

Member Function

CPtrList

CPtrList( INT_PTR nBlockSize = 10 );

CStringList

CStringList( INT_PTR nBlockSize = 10 );

Example

Below is a listing of the CObject-derived class CAge used in all the collection examples:

// 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
};

Below is an example of CObList constructor usage:

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

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

Requirements

Header: afxcoll.h

See Also

Reference

CObList Class

Hierarchy Chart

Other Resources

CObList Members