#include <iostream>
using namespace std;
class all{
int x,y;
public:
all(int a,int b):x(a),y(b){};
~all(){};
int add(){return (x+y);};
int sub(){return (x-y);};
int mul(){return (x*y);};
int div(){return (x/y);};
};
int main()
{
all a(4,2);
cout<<"add="<<a.add()<<endl;
cout<<"sub="<<a.sub()<<endl;
cout<<"mul="<<a.mul()<<endl;
cout<<"div="<<a.div()<<endl;
}
c++加减乘除小程序,类实例
最新推荐文章于 2023-07-28 00:45:50 发布