注册 登录
编程论坛 C++教室

线性表的合并

Amy10221102 发布于 2012-11-27 18:18, 541 次点击
template<class T>
SeqList<T> SeqList<T>:: Unite(const SeqList<T> lb)
{
    SeqList<T> lc(Length()+lb.Length());
    Node<T> *currentA=getFirst();
    Node<T> *currentB=lb.getFirst();
    int a=Length();
    int b=lb.Length();
    T x;
    for(int i=1;i<=a;i++)
    {
        x=currentA->data;
        lc.Insert(i,x);
        currentA=currentA->next;
    }
    for(int j=1;j<=b;j++)
    {
        x=currentB->data;
        if(lc.Search(x)==0)
            {lc.Insert(a+j,x);}
        currentB=currentB->next;
    }
    return lc;
}
在main()中调用la.Unite(lb);
c:\users\administrator\desktop\实验二\seqlist.h(219) : error C2664: '__thiscall SeqList<int>::SeqList<int>(const class SeqList<int> &)' : cannot convert parameter 1 from 'int' to 'const class SeqList<int> &'
        Reason: cannot convert from 'int' to 'const class SeqList<int>'
        No constructor could take the source type, or constructor overload resolution was ambiguous
        d:\program files\microsoft visual studio\vc98\include\xstring(79) : while compiling class-template member function 'class SeqList<int> __thiscall SeqList<int>::Unite(const class SeqList<int>)'
执行 cl.exe 时出错.


这是怎么回事啊,大神啊!!!求解!!!!
2 回复
#2
stophin2012-11-27 22:39
在main()中调用la.Unite(lb);
lb是int类型的就会出错,应该是SeqList<int>类型的
#3
Amy102211022012-11-28 13:27
回复 2楼 stophin
昨晚检查了下,发现是忘记写带参的构造函数 了
1