c++顺序表链表有关功能的实现.doc

c++顺序表链表有关功能的实现.doc

#include iostream using namespace std; const int MaxSize=100; template class T //模板类 class SeqList { public: SeqList() {length=0;} //无参构造函数 SeqList(T a[],int n); //有参构造函数 ~SeqList(){} //析构函数 int Length() {return length;} //求线性表长度 T Get(int i); //按位查找 int Locate(T x); //按值查找 void Insert (int i, T x); // 插入函数 T Delete(int i); //删除函数 void PrintList(); //遍历线性表,按序号依次输出各个元素。 private: T data[MaxSize]; int length; }; templateclass T? SeqListT::SeqList(T a[],int n) //有参构造函数 { if(nMaxSize)throw参数非法; for(int i=0;in;i++) data[i]=a[i]; length=n; } template class T void SeqListT::Insert(int i,T x) //插入函数 {

文档评论(0)

1亿VIP精品文档

相关文档