谁能帮我找错误
#include<iostream.h>template<class T>
struct Node
{
T data;
Node<T>*next;
};
template <class T>
class LinkList
{
public:
LinkList()
{
first=new Node<T>;first->next=NULL;
}
LinkList(T a[],int n);
~LinkList();
int length();
T Get(int i);
int locate(T x);
void Insert(int i,T x);
T Delete(int i);
void PrintList();
private:
Node<T>* first;
};
template<class T>
LinkList::LinkList(T a[],int n)
{
{
first=new Node<T>;
first->next=NULL;
for(int i=0;i<n;i++)
{
s=new Node<T>;
s->data=a[i];
first->next=next->next;
first->next=s;
}
}
template<class T>
LinkList::~LinkList()
{
Node<T>*p=first;
while(p)
{
Node<T>*q=p;
p=p->next;
delete q;
}
}
template<class T>
LinkList::Get(int i)
Node *p=first->next;
int j=1;
while(p&&j<i)
{
p->p->next;
j++;
}
if(!p)
throw"位置";
else return p->data;
}
template <class T>
void LinkList::Insert(int i,T x)
{
Node<T>*p=first;
int j=0;
while(p&&j<i-1)
{
p=p->next;
j++;
}
if(!p)throw"位置";
else
{
Node<T> s->data=x;
s->next=p->next;
p->next=s;
}
}
template <class T>
T LinkList::Delete(int i)
{
Node<T>p=first;
int j=0;
While(p&&j<i-1)
{
p=p->next;
j++;
}
if(!p&&!p->next)
throw"位置";
else{
Node*q=p->next;
Node<T> x=q->data;
p->next=q->next;
delete q;
return x;
}
}
template <class T>
void LinkList::PrintList()
{
Node<T>p=first->next;
while(p)
{
cout<<p->data<<endl;
p=p->next;
}
}#include <iostream.h>
#include"LinkList.h"
void main( )
{
int r[ ]={10,9,8,7,6,5,4,3,2,1};
LinkList <int> a( r , 10 );
cout<<"原表为:"<<endl;
a.PrintList();
cout<<endl;
a.Insert(1,-2); //执行插入操作;
a.Insert(2,-1);
a.Insert(3,0 );
cout<<"执行插入后输出为:"<<endl;
a.PrintList();
cout<<endl;
a.Delete(0);
a.Delete(-1);
a.Delete(-2);
cout<<"执行删除后输出为:"<<endl;
a.PrintList();
cout<<endl;
cout<<"按位查找第二个元素:"<<endl;
cout<<"第 5 个元素为: ";
cout<<a.Get(5)<<endl; //查找链表中第 5 个元素
cout<<endl;
}
谁能告诉我哪错了