求助,帮我看看这段程序!
#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)
可是我怎么都找不到在哪里?
请指教,谢谢啦!