📄 e2.cpp
字号:
#include<iostream.h>
class RMB
{
public:
RMB(double d){yuan=(int)d;jf=(int)((d-yuan)*100);}
void display()
{
cout<<(yuan+jf/100.0)<<endl;
}
RMB operator +(RMB d){return RMB(yuan+d.yuan+(jf+d.jf)/100.0);}
//人民币加的运算符重载
RMB operator *(double rate){return RMB((yuan+jf/100.0)*rate);}
private:
unsigned int yuan;//元
unsigned int jf;//角分
};
RMB expense2(RMB pricipal,double rate)
{
RMB interest=pricipal*rate;//本金乘利息(重载)
return pricipal+interest;//连带利(重载)
}
void main()
{
RMB x=10000.10;
double yrate=0.035;
expense2(x,yrate).display();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -