**************.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;
}
不懂
追答int main(){ double a,b,d;char c; cout>c; cout>a>>b; math A(a,c,b,d); A.show(); return 0;}