EXPLORATION 57

image

Project 3: Currency Type

It’s time for another project. You’re going to continue building on the fixed type from Project 2 and incorporate what you’ve learned about locales and I/O. Your task this time is to write a currency type. The value is stored as a fixed-point value. I/O is formatted using the get_money and put_money manipulators.

Make sure you can add two currency amounts to get a currency value, subtract two currency amounts to get currency, multiply and divide currency by an integer or rational value to get a currency result, and divide two currency values to get a rational result.

As with any project, start small and ...

Get Exploring C++ 11, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.