【求助】数据结构题= =

楼主

太阳出世 [离线]

0☆☆☆☆☆

发帖数:116 积分:362
1楼

显示错误 undefined reference to `operator+(seqList<int> const&, seqList<int> const&)
程序在这里:+法,=,复制构造都编了,但是还是有错= =
template <class elemType> class seqList;
template <class T> seqList<T> operator+(const seqList<T> &a,const seqList<T> &b);


template <class elemType>
class seqList:public List<elemType>
{
friend seqList<elemType> operator+(const seqList<elemType> &a,const seqList<elemType> &b);
………………
seqList(const seqList &a);
………………
seqList &operator=(const seqList &a);
………………
};


template <class T>
seqList<T> operator+(const seqList<T> &a,const seqList<T> &b)
{
int alen=a.Length(),blen=b.Length();
seqList<T> c(alen+blen);
for (int i=0;i<alen;i++)
c.data[i]=a.data[i];
for (int i=0;i<blen;i++)
c.data[i+alen]=b.data[i];
c.currentLength=alen+blen;
return c;
}


template <class elemType>
seqList<elemType>::seqList(const seqList<elemType> &a)
{
data=new elemType[a.maxSize];
if (!data) throw IllegalSize();
for (int i=0;i<a.currentLength;i++)
data[i]=a.data[i];
maxSize=a.maxSize;
currentLength=a.currentLength;


template <class elemType>
seqList<elemType> &seqList<elemType>::operator=(const seqList<elemType> &a)
{
if (this==&a) return *this;
delete [] data;
data=new elemType[a.maxSize];
if (!data) throw IllegalSize();
for (int i=0;i<a.currentLength;i++)
data[i]=a.data[i];
maxSize=a.maxSize;
currentLength=a.currentLength;
return *this;
}



发表于 2014/8/29 21:11:27

ivan [离线]

1★☆☆☆☆

发帖数:142 积分:448
2楼

求挽尊



发表于 2014/8/30 1:17:11

恋人已满 [离线]

0☆☆☆☆☆

发帖数:109 积分:505
3楼

学弟表示编程什么的C++什么的西奈



发表于 2014/8/30 17:28:05

小猫鱼 [离线]

13

发帖数:364 积分:13163
4楼

为什么觉得把T改成elemtype就可以了



发表于 2014/8/31 11:29:07
返回本版
1

请您先 登录 再进行发帖

快速回复楼主