class ChainNode { friend class chain; //friend class,the class chain can use the param of ChainNode private: int data; ChainNode *link; }; class chain { private: ChainNode *first; public: chain(){first = new ChainNode; first = 0;} //相当于InitList ~chain(); //void create(); //create a list bool ListEmpty()const {return first == 0;} //检查是否为empty int Length()const; //the length of the chain bool find(int num, int &x) const; //查看特定位置元素 int Search (const int &e); //返回e 的位置 chain& ListInsert(int num, const int& e); //插入数据元素e, 在num的位置 chain& ListDelete(int num, int &x); //删除the place元素,and 赋值, 并返回这个chain //void MergList(SqList La, SqList Lb, SqList &Lc); //归并两个线性表 void displayElem(ostream &out); //遍历 //应该是输出到这个 ostream &out 里面。 }
c++学习笔记(17)线性链表的c++实现收获
最新推荐文章于 2024-08-18 15:07:23 发布