Упражнение 12
Предефиниране
на операции
Задача 1: (Big C++ 14.2 Case Study: Fractional Numbers
- p. 551)
Да се реализира клас за прости дроби с аритметичните операции, вход
и изход.
Задача 2: (Big C++ Exercise P14.5)
Define a class Money, which maintains two integer data fields, dollars and
cents. Overload arithmetic operators, comparison operators, and
input and output operators for your class. Should you overload the
* and / operators? What argument types should they accept?
Overload the % operator so that if n is a float- ing-point value,
n % m yields n percent of the money amount m.