网站首页  词典首页

请输入您要查询的计算机术语:

 

术语 CObList::CObList
释义 CObList::CObList

CObList( int nBlockSize = 10 );

参数:
nBlockSize扩展列表所需的内存分配的粒度大小。

说明:
构造一个空CObject指针列表。当列表增大后,以nBlockSize为单位分配内存。若内存分配失败,那么将产生CMemoryException。

示例:
下面列出CObject派生类CAged,它用于所有收集示例中:
// Simple CObject-derived class for CObList 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
};

下面为CObList构造函数用法的例子:
CObList list( 20 ); // List on the stack with blocksize = 20.
CObList* plist = new CObList; // List on the heap with default blocksize.
随便看

 

MFC类库中文详解手册包含4274条MFC类库参考词条,基本涵盖了Microsoft基本类库中的类、全局函数、全局变量和宏的内容,是计算机编程的有利工具。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 14:29:48