24.1 MONEY MATTER
In this section, we have four classes which are very similar in nature. The difference is mainly in the methods defined.
class Money
{ private: long rupee, paise ; public : Money( long a, long b) ; Money(); void show(); } ;
class Amount
{ private: long rupee, paise ; public: Amount() ; Amount(long p, long q) ; void show() ; friend Amount operator +( Amount a1 , Amount a2 ); Amount validate (Amount a); } ;
Class amount is improvement over money. Normally, we need adding two amounts. Hence, an operator function is provided. While adding the value of Paisa may become 100 or more. Therefore, we need the method validate. Here, method validates and returns the corrected amount. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access