| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 541 人关注过本帖
标题:线性表的合并
只看楼主 加入收藏
Amy10221102
Rank: 1
来 自:福建
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-11-27
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:2 
线性表的合并
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 时出错.


这是怎么回事啊,大神啊!!!求解!!!!
搜索更多相关主题的帖子: next 线性表 
2012-11-27 18:18
stophin
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:3
帖 子:227
专家分:618
注 册:2010-3-26
收藏
得分:14 
在main()中调用la.Unite(lb);
lb是int类型的就会出错,应该是SeqList<int>类型的
2012-11-27 22:39
Amy10221102
Rank: 1
来 自:福建
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-11-27
收藏
得分:0 
回复 2楼 stophin
昨晚检查了下,发现是忘记写带参的构造函数 了

完成一个代码总是要花费甚大的精力啊。。。。
2012-11-28 13:27
快速回复:线性表的合并
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014513 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved