
c++程序错误
#include<iostream>#include<string>usingnamespacestd;classxy{public:xy(intc){a1=c;cout...
#include<iostream>
#include<string>
using namespace std;
class xy
{
public:
xy(int c)
{
a1=c;
cout<<"力拔山兮气盖世!"<<endl;
}
int a1;
};
class lb
{
public:
lb(int c)
{
a2=c;
cout<<"大风起兮云飞扬!"<<endl;
}
int a2;
};
class yx:public xy,public lb
{
public:
yx();
yx(int a,int b,int c):xy(a),lb(b)
{
a3=c;
}
int a3;
};
int main()
{
yx YX;
YX(1,2,3);
cout<<"项羽的特点a1 "<<YX.a1<<endl<<"刘邦特点a2 "<<YX.a2<<endl<<"英雄特点a3 "<<YX.a3<<endl;
system("pause");
return 0;
}
如题有一个错误在main中的YX一行,错误是error C2064: term does not evaluate to a function。求大神解答,这是个继承的程序。。。 展开
#include<string>
using namespace std;
class xy
{
public:
xy(int c)
{
a1=c;
cout<<"力拔山兮气盖世!"<<endl;
}
int a1;
};
class lb
{
public:
lb(int c)
{
a2=c;
cout<<"大风起兮云飞扬!"<<endl;
}
int a2;
};
class yx:public xy,public lb
{
public:
yx();
yx(int a,int b,int c):xy(a),lb(b)
{
a3=c;
}
int a3;
};
int main()
{
yx YX;
YX(1,2,3);
cout<<"项羽的特点a1 "<<YX.a1<<endl<<"刘邦特点a2 "<<YX.a2<<endl<<"英雄特点a3 "<<YX.a3<<endl;
system("pause");
return 0;
}
如题有一个错误在main中的YX一行,错误是error C2064: term does not evaluate to a function。求大神解答,这是个继承的程序。。。 展开
1个回答
展开全部
对象初始化用的不对,
yx YX;
YX(1,2,3);
这两句改成这样试试:
yx YX(1,2,3);
yx YX;
YX(1,2,3);
这两句改成这样试试:
yx YX(1,2,3);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询