线性表_顺序表

1.seqlist.h
头文件对于顺序表的定义
#ifndef SEQLIST_H
#define SEQLIST_H
const int MAXSIZE = 100;
template
class SeqList{
private:
DataType data[MAXSIZE];
int length;
public:
SeqList();
SeqList(DataType a[],int n);
//功能api
void printList();
int Locate(DataType x);
bool Get(int pos,DataType &element);
bool Delete(int pos,DataType &element);
bool Insert(int pos,DataType x);
bool Insert(DataType x);
~SeqList();
};
#endif // SEQLIST_H_INCLUDED
2.seqlist.cpp
// api的实现
#include"SeqList.h"
#include
template
SeqList::SeqList(){
length = 0;
}
template
SeqList::SeqList(DataType a[],int n){
length=n;
for(int i = 0; i < n; i++)
{
data[i]=a[i];
}
}
using namespace std;
template
void SeqList::printList()
{
for(int i = 0; i < length; i++)
{
cout<[InvalidCharacterError: "DATA[I]<<"" did not match the Name production]