#include
#include
#include
using namespace std;
const int N=5;
template
class SeqList
{
public:
SeqList(){length=0;}
SeqList(DataType a[],int n);
~SeqList(){}
int Length(){return length;}
DataType Get(int i);
int Locate(DataType x);
void Insert(int i,DataType x);
DataType Delete(int i);
void PrintList();
DataType data[N];
private:
int length;
};
struct M
{
char SeqList;
char Get;
char Locate;
char Insert;
char Delete;
};
struct player
{
int number;
char name;
char score;
};
template
SeqList::SeqList(DataType a[],int n)
{
int i,n;
for(i=0;i
data[i]=a[i];
length=n;
Menu();
};
template
DataType SeqList::Get(int i)
{
int i;
if(ilength)
throw"查找位置非法";
else
return data[i-1];
Menu();
};
template
int SeqList::Locate(DataType x)
{
int i;
for(i=o;i
if(data[i]==x)
return i+1;
return 0;
Menu();
}
template
void SeqList::Insert(int i,DataType x)
{
int i,j;
if(length>=N)
throw"上溢";
if(ilength)
throw"位置";
for(int j j=length;j>=i;j--)
data[j]=data[j-1];
date[i-1]=x;
length++;
Menu();
};
template
DataType SeqList::Delete(int i)
{
int i,j;
if(ilength)
throw "weizhi";
x=data[i-1];
for(j=i;j<length;j++)
data[j-1]=data[j];
length--;
return x;
Menu();
};
void Menu()
{
char choice;
SeqList Func;
system("cls");
cout<<" 运动员信息 "<
cout
cout
cout
cout
cout
cout
cin>>choice;
switch(choice)
{
case'1':
Func.SeqList(n);
break;
case'2':
Func.Get(i);
break;
case'3':
Func.Insert(i);
break;
case'4':
Func.Delete(i);
break;
case'5':
Func.Locate(i);
break;
default:
break;
}
}
int main()
{
player a[N];
int M;
cout<<"请输入运动员信息:"<
for(M=0;M
cin>>a[M].name>>a[M].number>>a[M].score;
Menu();
return 0;
}
在用类编辑这个顺序表之后,在最后用switch的时候出现的这个错误,应该怎么改?
下面是错误提示:
发好的.cpp
H:\撒旦\发好的.cpp(111) : error C2039: 'SeqList' : is not a member of 'SeqList'
H:\撒旦\发好的.cpp(111) : error C2065: 'n' : undeclared identifier
H:\撒旦\发好的.cpp(114) : error C2065: 'i' : undeclared identifier
执行 cl.exe 时出错.
发好的.exe - 1 error(s), 0 warning(s)