Dealing with money in C++

I'm currently learning C++.

I have to write a simple class Money that performs calculations involving dollars and cents where arithmetic has to be accurate to the last cent using the 4/5 rounding rule. And I need to implement a monetary amount as the number of cents in a long int.

I have never dealt before with monetary amounts so I'm having some troubles in understanding how to get the best from my class. I know that I shouldn't represent monetary amounts with floats but I have some questions about how to implement this class :

How can I get the number of cents that compose a monetary amount ? Like 1.3005, 13.45 and put them in a long int without losing data ?

When should I round values, before or after using data in arithmetic operations ?
When should I round values, before or after using data in arithmetic operations ?


Once, at the very end, when you have to display it to someone who only likes whole cent values.
Topic archived. No new replies allowed.