This documentation is archived and is not being maintained.

CObList::CObList 

Constructs an empty CObject pointer list.


CObList(
   INT_PTR nBlockSize = 10 
);

Parameters

nBlockSize

The memory-allocation granularity for extending the list.

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 );

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;
    }
    void* operator new(size_t nSize);
    void* operator new(size_t nSize, LPCSTR lpszFileName, int nLine);
    void operator delete(void* p);
    void operator delete(void* p, LPCSTR lpszFileName, int nLine);
#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.
Show: