#include<iostream>
using namespace std;
class Wallet{
public:
Wallet operator+(Wallet &c1);
Wallet operator-(Wallet &c1);
Wallet operator*(Wallet &c1);
Wallet operator/(Wallet &c1);
void display();
void input();
private:
float rmb,jpy,usd;
};
void Wallet::display(){cout<<"("<<rmb<<","<<jpy<<","<<usd<<")"<<endl;}
void Wallet::input(){cin>>rmb>>jpy>>usd;}
Wallet Wallet::operator+(Wallet &c1){
Wallet c;
c.rmb=rmb+c1.rmb;
c.jpy=jpy+c1.jpy;
c.usd=usd+c1.usd;
return c;
}
Wallet Wallet::operator-(Wallet &c1){
Wallet c;
c.rmb=rmb-c1.rmb;
c.jpy=jpy-c1.jpy;
c.usd=usd-c1.usd;
return c;
}
Wallet Wallet::operator*(Wallet &c1){
Wallet c;
c.rmb=rmb*c1.rmb;
c.jpy=jpy*c1.jpy;
c.usd=usd*c1.usd;
return c;
}
Wallet Wallet::operator/(Wallet &c1){
Wallet c;
c.rmb=rmb/c1.rmb;
c.jpy=jpy/c1.jpy;
c.usd=usd/c1.usd;
return c;
}
wallet
最新推荐文章于 2024-09-10 08:28:20 发布