#include
using namespace std;
template
struct Node
{
T data;
Node *next;
};
template
class BLink
{
public:
BLink()
{}/*构造函数,因为你想先定义对象,在赋值,故应该把系统默认的构造函数重新定义*/
BLink(T a[],int n);
~BLink()
{}/*你忘了定义了*/
int Length();
T Get(int i);
void Insert(int i,T x);
int Locate(T x);
T Delete(int i);
void Display();
protected:
Node
};
template
T BLink
{
p=first->next;
j=1;
while(p&&j {
p=p->next;
j++;
}
if(!p)throw"the numble of the elment is wrong";
else return p->data;
}
template
int BLink
{
i=1;
p=first->next;
while(!p)
{
p=p->next;
i++;
}
return i;
}
template
void BLink
{
p=first;
j=0;
while(p&&j
p=p->next;
j++;
}
if(!p)throw"the numble of the elment is wrong";
else{
s=new Node
s->data=x;
s->next=p->next;
p->next=s;
}
}
template
int BLink
{
p=first;
j=0;
for(j=0;;j++)
{
p=p->next;
if(p->data==x)return j;
if(!p)throw"the numble of the elment is wrong";
}
}
template
T BLink
{
p=first;
j=0;
while(p&&j
p=p->next;
j++;
}
if(!p||!p->next)throw"the numble of the elment is wrong";
else{
T x;
s=new Node
s=p->next;
x=s->data;
p->next=s->next;
delete s;
return x;
}
}
template
BLink
{
first=new Node
r=first;
for(i=0;i
s=new Node
s->data=a[i];
r->next=s;
r=s;
}
r->next=NULL;//创建完表单要将尾节点的指针域置空
}
template
void BLink
{
p=first->next;
while(p)
{
cout<
}
}
void main()
{
int a[100];
int n;
cout<<"the numbles of the elments is:"<<'\n';
cin>>n;
for(int i=0;i
cout<<"a["< cin>>a[i];
}
BLink
}