Share via


CObList::CObList

This constructor constructs an empty CObject pointer list. As the list grows, memory is allocated in units of nBlockSize entries. If a memory allocation fails, a CMemoryException is thrown.

CObList(
int nBlockSize = 10 ); 

Parameters

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

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

Requirements

**  Windows CE versions:** 1.0 and later  
  Header file: Declared in Afxcoll.h
  Platform: H/PC Pro, Palm-size PC, Pocket PC