I am creating a Money class for a school assignment. I defined the conversion from Money to double, I have a constructor for Money that accepts int, another constructor takes a double number, and I overloaded the + operator to add two objects of type Money. The error message appears when I try to do something like myMoney + 10where my myMoney is an object of type Money, and 10 is obviously an integer. Here is the rest of the relevant code:
class Money {
private:
int dollars;
int cents;
public:
Money(double r);
Money(int d) : dollars(d), cents(0) {}
operator double();
}
Money operator+(Money a, Money b) {
double r = double(a) + double(b);
return Money(r);
}
Money::operator double() {
return dollars+double(cents)/100;
}
Money::Money(double r) {
...
}
, Money(double(myMoney)+10), , , , . - ?