#include <iostream>using namespace std;class RMB
{
private:double yuan;double jiao;double fen;static int count;
public:RMB(){++count;}RMB(double yuan,double jiao,double fen):yuan(yuan),jiao(jiao),fen(fen){++count;}~RMB(){count--;cout << "析构函数被调用,当前count=" << count << endl;}void show(){// if(fen>9)// {// fen = fen - 10;// jiao=jiao+1;// }// else if(jiao>9)// {// jiao= jiao -10;// yuan=1+yuan;// }// if(fen <0)// {// jiao=jiao-1;// fen = fen +10;// }// if(jiao <0)// {// yuan=yuan-1;// jiao = jiao+10;// }// else if(yuan <0)// {// cout << "钱不够了" << endl;// }cout << yuan << " " << jiao <<" " << fen << endl;}static int pos(){return count;}const RMB operator+(const RMB &R)const{RMB t;t.yuan = yuan + R.yuan;t.jiao = jiao + R.jiao;t.fen = fen + R.fen;return t;}const RMB operator-(const RMB &R)const{RMB t;t.yuan = yuan - R.yuan;t.jiao = jiao - R.jiao;t.fen = fen - R.fen;return t;}bool operator>(const RMB &R)const{if(yuan > R.yuan){return true;}else if (jiao > R.jiao){return true;}else if(fen > R.fen){return true;}else{return false;}}RMB &operator--(){--yuan;--jiao;--fen;return *this;}const RMB operator--(int){RMB t;t.yuan=yuan--;t.jiao=jiao--;t.fen=fen--;return t;}};int RMB::count=0;int main()
{RMB s1(3,2,1);RMB s2(1,2,3);RMB s3;cout << "count的值: " << RMB::pos()<<endl;s3 = s1 + s2;s3.show();s3 = s1 - s2;s3.show();cout << "count的值: " << RMB::pos()<<endl;cout << "---------------" << endl;if(s1>s2){cout << "ture" << endl;}else{cout << "false" << endl;}cout << "count的值: " << RMB::pos()<<endl;cout << "---------------" << endl;s3 = s1--;s1.show();s3.show();s3 = --s1;s1.show();s3.show();cout << "count的值: " << RMB::pos()<<endl;cout << "---------------" << endl;return 0;
}

