- /*基于数据成员是指向一个数组的指针来实现的list*/
- /*由于数据成员包含动态分配的内存,所以还要自己定义拷贝构造和赋值函数
- *以及析构函数
- */
- /*2011.4.10 by winlin*/
- #ifndef DYNAMIC_ARRAY_LIST_H
- #define DYNAMIC_ARRAY_LIST_H
- #include <iostream>
- typedef int elementTypt;
- class list
- {
- public:
- list(int maxSize=1024);
- ~list();
- list(const list& origList);
- const list& operator =(const list& rightList);
- bool empty() const;
- void insert(elementTypt item,int pos);
- void erase(int pos);
- void display(ostream& out) const;
- private:
- int m_Size; //the current size of list
- int m_Capacity; //the capacity of the list
- elementTypt* m_Array; //the point point to the dynamic array
- };
- ostream& operator <<(ostream& out,const list& alist);
- #endif // DYNAMIC_ARRAY_LIST_H