一道求差集的题
#include <iostream>using namespace std;
template<class ElemType>
class SqList
{
protected:
int count;
int maxsize;
ElemType*elems;
public:
SqList(int size=DEFAULT_SIZE);
virtual ~SqList();
int Length()const;
bool Empty()const;
void Clear();
void Traverse(void(*Visit)(ElemType &));
statusCode GetElem(int position,ElemType &e)const;
statusCode SetElem(int position,const ElemType &e);
statusCode Delete(int position,ElemType &e);
statusCode Insert(int position,const ElemType &e);
SqList(const SqList<ElemType>©);
SqList<ElemType>&operator=(const SqList<ElemType>©);
};
bool SqList<ElemType>::Full()const_const()
{
return count==maxSize;
}
void SqList<ElemType>::Init(int size)
{
maxsize=size;
if(elems!=NULL)delete []elems;
elems=new ElemType[maxSize];
count=0;
}
SqList<ElemType>::SqList(int size)
{
elems=NULL;
Init(size);
}
SqList<ElemType>::~SqList()
{
delete []elems;
}
SqList<elemTyoe>::Length()const
{
return count;
}
bool SqList<ElemType>::Empty()const
{
return count==0;
}
void SqList<ElemType>::Clear()
{
count=0;
}
void SqList<ElemType>::Traverse(void(*visit)(ElemType &))
{
for(int curPosition=1;curPosition<=Length();curPosition++)
{
(*visit)(elems[curPosition-1]);
}
}
statusCode SqList<ElemType>::GetElem(int position;ElemType &e)const
{
if(position<1||position>Length())
{
return NOT_PRESENT;
}
else
e=elems[position-1];
return ENTRY_FOUND;
}
statusCode SqList<ElemType>::SetElem(int position;const ElemType &e)
{
if(position<1||position>Length())
{
return RANGE_ERROR;
}
else
{
elems[position-1]=e;
return SUCCESS;
}
}
void difference(const SqList<ElemType>&la,const SqList<ElemType>&lb,
const SqList<ElemType>&lc)
{
ElemType aItem,bItem;
lc.Clear();
for(int aPosition=1;aPosition<=la.length();aPosition++)
{
la.GetElem(aPosition,aItem);
bool isExist=flase;
for(int bPosition=1;bPosition<=la.length();bPosition++)
{
lb.GetElem(bPosition,bItem);
if(aItem=bItem)
{
isExist=true;
break;
}
}
if(!isExist)
{
lc.Insert(lc.Length()+1,aItem);
}
}
}
大神们帮忙改改,给个能运行的完整代码,谢谢