00001 #ifndef _CURRENCY_H
00002 #define _CURRENCY_H
00003
00004 #include <iostream>
00005
00006 #include <string>
00007
00008 using namespace std;
00009
00010
00011
00012
00022 class Currency {
00023
00024 public:
00025
00026 Currency();
00027 Currency(const Currency&);
00028 Currency(int rhs);
00029 Currency(float rhs);
00030 Currency(double rhs);
00031 Currency(int integer, int fraction);
00032 ~Currency();
00033
00034 Currency& operator=(const Currency& rhs);
00035 Currency& operator=(const float rhs);
00036 Currency& operator=(const int rhs);
00037
00038 Currency& operator+=(const Currency& rhs);
00039 Currency& operator+=(const float rhs);
00040 Currency& operator+=(const int rhs);
00041
00042 Currency& operator-=(const Currency& rhs);
00043 Currency& operator-=(const float rhs);
00044 Currency& operator-=(const int rhs);
00045
00046 Currency& operator*=(const Currency& rhs);
00047 Currency& operator*=(const float rhs);
00048 Currency& operator*=(const int rhs);
00049
00050 Currency& operator/=(const Currency& rhs);
00051 Currency& operator/=(const float rhs);
00052 Currency& operator/=(const int rhs);
00053
00054 Currency operator+() const;
00055 Currency operator-() const;
00056
00057 operator int() const;
00058 operator float() const;
00059 operator double() const;
00060
00061 string toString() const;
00062
00063 friend Currency operator-(const Currency& lhs, const Currency& rhs);
00064 friend Currency operator-(const Currency& lhs, float rhs);
00065 friend Currency operator-(const Currency& lhs, int rhs);
00066
00067 friend Currency operator+(const Currency& lhs, const Currency& rhs);
00068 friend Currency operator+(const Currency& lhs, float rhs);
00069 friend Currency operator+(const Currency& lhs, int rhs);
00070
00071 friend Currency operator*(const Currency& lhs, const Currency& rhs);
00072 friend Currency operator*(const Currency& lhs, float rhs);
00073 friend Currency operator*(const Currency& lhs, int rhs);
00074
00075 friend Currency operator/(const Currency& lhs, const Currency& rhs);
00076 friend Currency operator/(const Currency& lhs, float rhs);
00077 friend Currency operator/(const Currency& lhs, int rhs);
00078
00079 friend bool operator<(const Currency& lhs, const Currency& rhs);
00080 friend bool operator<(const Currency& lhs, float rhs);
00081 friend bool operator<(const Currency& lhs, int rhs);
00082
00083 friend bool operator>(const Currency& lhs, const Currency& rhs);
00084 friend bool operator>(const Currency& lhs, float rhs);
00085 friend bool operator>(const Currency& lhs, int rhs);
00086
00087 friend bool operator==(const Currency& lhs, const Currency& rhs);
00088 friend bool operator==(const Currency& lhs, float rhs);
00089 friend bool operator==(const Currency& lhs, int rhs);
00090
00091 friend bool operator!=(const Currency& lhs, const Currency& rhs);
00092 friend bool operator!=(const Currency& lhs, float rhs);
00093 friend bool operator!=(const Currency& lhs, int rhs);
00094
00095 friend bool operator<=(const Currency& lhs, const Currency& rhs);
00096 friend bool operator<=(const Currency& lhs, float rhs);
00097 friend bool operator<=(const Currency& lhs, int rhs);
00098
00099 friend bool operator>=(const Currency& lhs, const Currency& rhs);
00100 friend bool operator>=(const Currency& lhs, float rhs);
00101 friend bool operator>=(const Currency& lhs, int rhs);
00102
00103 friend ostream& operator<<(ostream& os, const Currency& rhs);
00104
00105
00106 int value;
00107 };
00108
00109 #endif