#include <iostream>using namespace std;class FenShu{ public: FenShu(int Fen_Zi = 1, int Fen_Mu = 1); void add(const FenShu & a); void show(); int Fenzi(){return FenZi;} int Fenmu(){return FenMu;} int GCD(int FenZi,int FenMu); friend FenShu operator+(FenShu & a,const FenShu & b); friend FenShu operator-(FenShu & a,const FenShu & b); friend FenShu operator*(FenShu & a,const FenShu & b); friend FenShu operator/(FenShu & a,const FenShu & b); private: int FenZi; int FenMu;};FenShu::FenShu(int Fen_Zi, int Fen_Mu):FenZi(Fen_Zi),FenMu(Fen_Mu){}void FenShu::add(const FenShu & a){ FenZi += a.FenZi; FenMu += a.FenMu;}FenShu operator+(FenShu & a,const FenShu & b){ a.FenZi += b.FenZi; a.FenMu += b.FenMu; return a;}FenShu operator-(FenShu & a,const FenShu & b){ a.FenZi -= b.FenZi; a.FenMu -= b.FenMu; return a;}FenShu operator*(FenShu & a,const FenShu & b){ a.FenZi *= b.FenZi; a.FenMu *= b.FenMu; return a;}FenShu operator/(FenShu & a,const FenShu & b){ a.FenZi /= b.FenZi; a.FenMu /= b.FenMu; return a;}int FenShu::GCD(int FenZi,int FenMu){ while(FenMu != 0) { int temp = FenZi % FenMu; FenZi = FenMu; FenMu = temp; } return FenZi; }void FenShu::show(){ int Zire = FenZi / GCD(FenZi,FenMu); int Mure = FenMu / GCD(FenZi,FenMu); cout << "the result is : " << Zire << " / " << Mure << "\n"; }int main(){ FenShu a(6,2); a.show(); FenShu b; b.show(); a.add(b); a.show(); a + b; a.show(); }