return j;处提示j:未声明的标识符,求大神解答
vs2012吧
全部回复
仅看楼主
level 1
折刃之剑 楼主
#include<iostream>
#include"LinearList.h.h"
#include"Node.h.h"
#include<stdio.h>
template<class T>
class SingleList:public LinearList<T>
{
public:
SingleList();
~SingleList();
bool IsEmpty() const;
int Length() const;
bool Find(int i,T &x) const;
int Search(T x) const;
bool Insert(int i,T x);
bool Delete(int i);
bool Update(int i,T x);
void Clear();
void Output(ostream &out) const;
private:
Node<T> *first;
};
template<class T>
SingleList<T>::SingleList()
{
first=NULL;
n=0;
}
template<class T>
SingleList<T>::~SingleList()
{
Node<T> *p;
while(first)
{
p=first->link;
delete first;
first=p;
}
}
template<class T>
int SingleList<T>::Length() const
{
return n;
}
template<class T>
bool SingleList<T>::IsEmpty() const
{
return n==0;
}
template<class T>
bool SingleList<T>::Find(int i,T &x)const
{
if(i<0||i>n-1)
{
cout<<"Out Of Bounds";
return false;
}
Node<T> *p=first;
for(int j=0;j<i;j++)
{
p=p->link;
}
x=p->element;
return true;
}
template<class T>
int SingleList<T>::Search(T x)const
{
Node<T> *p=first;
for(int j=0;p&&p->element!=x;j++)
{
p=p->link;
}
if(p)
{
return j;
}
return -1;
}
2014年05月24日 04点05分 1
1