/*----------sqlist.h----------*/
#ifndef SQLIST_H
#define SQLIST_H
//起始下标为 1
//最大下标为 SIZE
const int SIZE(10);
//此处修改默认表长大小
template <typename Type> class Sqlist{
public:
Sqlist(int maxsize=SIZE)
{
while(maxsize<1){
cout << "设置最大表长有误,请重新设置->: " ;
cin >> maxsize;
}
MaxSize=maxsize;
data=new Type[MaxSize+1]; // data[MaxSize] 为表满状态
last=0; //空表状态
}
~Sqlist()
{
delete [] data;
}
void Clear() //清空顺序表
{
last=0;
}
bool Empty() //判空
{
if(last==0)
return true;
else
return false;
}
status push_back(const Type &value) //压入(后插)
{
if(last==MaxSize){
cerr << "顺序表已满,操作失败!