| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 815 人关注过本帖
标题:求助,帮我看看这段程序!
取消只看楼主 加入收藏
tfbob
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2008-1-9
收藏
 问题点数:0 回复次数:3 
求助,帮我看看这段程序!
#include<iostream.h>
class base{
    int a;
public:
    base(int sa)
    {
        a=sa;
        cout<<"constructing base"<<endl;
    }
};
class base1:virtual public base{
    int b;
public:
    base1(int sa,int sb):base(sa)
    {
        b=sb;
        cout<<"Constructing base1"<<endl;
    }
};
class base2:virtual public base{
    int c;
public:
    base2(int sa,int sc):base(sa)
    {
        c=sc;
        cout<<"Constructing base2"<<endl;
    }
};

class derived:public base1,public base2
{
     int d;
public:
    derived(int sa,int sb,int sc,int sd):base(sa),base1(sb),base2(sc)
    {
        d=sd;
    }
};
 int main()
{
    derived obj(2,4,6,8);

    return 0;
}
运行错误
--------------------Configuration: E4_12 - Win32 Debug--------------------
Compiling...
E4_12.CPP
E:\vc\E4_12\E4_12.CPP(43) : error C2664: '__thiscall base1::base1(const class base1 &)' : cannot convert parameter 1 from 'int' to 'const class base1 &'
        Reason: cannot convert from 'int' to 'const class base1'
        No constructor could take the source type, or constructor overload resolution was ambiguous
E:\vc\E4_12\E4_12.CPP(43) : error C2664: '__thiscall base2::base2(const class base2 &)' : cannot convert parameter 1 from 'int' to 'const class base2 &'
        Reason: cannot convert from 'int' to 'const class base2'
        No constructor could take the source type, or constructor overload resolution was ambiguous
执行 cl.exe 时出错.

E4_12.OBJ - 1 error(s), 0 warning(s)


可是我怎么都找不到在哪里?
请指教,谢谢啦!
搜索更多相关主题的帖子: derived include public 
2008-01-14 10:14
tfbob
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2008-1-9
收藏
得分:0 
十分感谢!好了!
2008-01-19 13:57
tfbob
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2008-1-9
收藏
得分:0 
我也不是学计算机的,
我是光电的,也是爱好,我从12岁开始学c语言,到了26岁了还没有把编程学好,
2008-01-20 16:10
tfbob
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2008-1-9
收藏
得分:0 
惭愧啊!
2008-01-21 18:48
快速回复:求助,帮我看看这段程序!
数据加载中...
 
   



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

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