Money.h

00001 #ifndef MONEY_H                         // avoid repeated expansion
00002 #define MONEY_H
00003 
00004 #include <iostream>
00005 
00007 class Money {
00008 
00009  public:
00010 
00017   explicit Money(int dollars=0, int cents=0);
00018 
00019 
00026   int getDollars() const;
00027 
00034   int getCents() const;
00035 
00039   bool isNegative() const;
00040 
00045   Money operator+(const Money& other) const;
00046 
00050   void operator+=(const Money& other);
00051 
00056   Money operator-(const Money& other) const;
00057 
00061   void operator-=(const Money& other);
00062 
00066   Money operator-() const;
00067 
00072   bool operator<(const Money& other) const;
00073 
00078   bool operator<=(const Money& other) const;
00079 
00084   bool operator>(const Money& other) const;
00085 
00090   bool operator>=(const Money& other) const;
00091 
00096   bool operator==(const Money& other) const;
00097 
00102   bool operator!=(const Money& other) const;
00103 
00109   Money operator*(double factor) const;
00110 
00111  private:
00112   int dollars;
00113   int cents;
00114   void normalize();
00115 };
00116 
00123 std::ostream& operator<<(std::ostream& os, const Money& value);
00124 
00131 Money operator*(double factor, const Money& m);
00132 
00133 
00134 #endif

Generated on Tue Sep 16 23:25:45 2008 by  doxygen 1.4.6