我给你做好了!
头文件“a.h”:
#include
using namespace std;
class Opera
{
public:
void get();
void add();
void red();
void mul();
void div();
void quyu();
char get_c(){return c;}
private:
int a;
int b;
char c;
};
Opera.cpp文件:
#include
#include"a.h"
using namespace std;
void Opera::get()
{
cout<<"请输入你要计算的式子:"<
}
void Opera::add()
{
cout<}
void Opera::div()
{
cout<}
void Opera::mul()
{
cout<}
void Opera::red()
{
cout<
void Opera::quyu()
{
cout<}
main.cpp文件:
#include
#include"a.h"
using namespace std;
int main()
{
Opera o;
o.get();
switch(o.get_c())
{
case '+':o.add();break;
case '-':o.red();break;
case '*':o.mul();break;
case '/':o.div();break;
case '%':o.quyu();break;
}
return 0;
}
这是三个文件里的东西,你自己新建一个工程,按照这里的命名方式复制过去就行了!
#include
int main()
{
int x,y;
char ch;
cin >> x >> ch >> y;
if (ch == '*')
{
cout << x << "*" << y << " = " << x*y;
}
if (ch == '+')
{
cout << x << "+" << y << " = " << x+y;
}
if (ch == '-')
{
cout << x << "-" << y << " = " << x-y;
}
if (ch == '/')
{
cout << x << "/" << y << " = " << x/y;
}
if (ch == '%')
{
cout << x << "%" << y << " = " << x'%y;
}
return 0;
}