C++问题 g:\c++作业\sy4-6ljq124.cpp(9) : error C2661: 'math::math' : no overloaded function takes 2

**************.h***************

#include<iostream.h>
class math
{
private:
double x,y,z;char ch;
public:
math(double a,char c,double b,double d){x=a;y=b;ch=c;z=d;}
double caculate();
void show(){cout<<x<<ch<<y<<'='<<z<<endl;}
};
double math::caculate()
{
switch(ch)
{
case '+':z=x+y;break;
case '-':z=x-y;break;
case '*':z=x*y;break;
case '/':z=x/y;break;
default:cout<<"输入有误,请重新输入!"<<endl;
}
}

*********************.cpp********************

#include"sy4-6ljq124.h"
int main()
{
double a,b;char c;
cout<<"请输入一种运算符号"<<endl;
cin>>c;
cout<<"请输入两个数"<<endl;
cin>>a>>b;
math A(a,b);
A.show();
return 0;
}

构造函数4个参数 你main函数调用才两个追问

不懂

追答

int main(){ double a,b,d;char c; cout>c; cout>a>>b; math A(a,c,b,d); A.show(); return 0;}

温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

大家正在搜

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网