术语 | CObList::CObList | ||
释义 | CObList::CObList CObList( int nBlockSize = 10 ); 参数:
说明: 构造一个空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基本类库中的类、全局函数、全局变量和宏的内容,是计算机编程的有利工具。