Overload operators '+', '-' and '*' so that the program below can be compiled.
Also write a function Òoutput()Ó that outputs the amount.
The cent amount must not be negative (if it is, the euro amount is reduced accordingly) and
the cent amount must not be in three digits (the euro amount increases until the cent amount is in two digits).
The interest rate increases the euro/cent amount by the respective factor.
#include <iostream>
#include <cstdlib>
using namespace std;
class euro
{
private:
int euro;
int cent;
};
int main()
{
Euro myMoney(100.80), yourMoney(45.30), fine(25.80), ourMoney;
double interestrate = 3.5;
ourMoney = myMoney + yourMoney;
ourMoney.output();
ourMoney = ourMoney - fine;
ourMoney.output();
ourMoney = ourMoney.operator*(interestrate);
ourMoney.output();
system("pause");
return 0;
}
\ No newline at end of file
Overload operators '+', '-' and '*' so that the program below can be compiled.
Also write a function "output()" that outputs the amount.
The cent amount must not be negative (if it is, the euro amount is reduced accordingly) and
the cent amount must not be in three digits (the euro amount increases until the cent amount is in two digits).
The interest rate increases the euro/cent amount by the respective factor.
#include <iostream>
using namespace std;
class euro
{
private:
int euro;
int cent;
};
int main()
{
Euro myMoney(100.80), yourMoney(45.30), fine(25.80), ourMoney;