/* This is the body of the Money ADT/class specificed in money.h Compile (but do not link, like this g++ -c moneyv.cc It will then create a moneyv.o ready to be linked with other modules... These routines are default routines. They use routines that must be defined in a derived class before they can be used in a program. */ #include "moneyv.h" //The following are defined in terms of the "pure vrtual" functions of // the abstract class Money Money Money::operator-(Money b) { return *this + (- b) ; } int Money::operator>(Money a, Money b) { return b < a ; } int Money::operator>=(Money a, Money b) { return (a > b) || (a == b) ; } int Money::operator<=(Money a, Money b) { return b >= a ; } int Money::operator!=(Money a, Money b) { return !( a==b); } /* This is the body of the Dollars class specificed in moneyv.h */ #include //Initalizations and casts. Dollars::Dollars() { d=0; c=0; } //clean initial values Dollars::Dollars(const int n) { d=n ; c=0; } //conversion(cast) Dollars::Dollars(const int d0, int c0) { d=d0; c=(d<0? -c0 : c0 ); } Dollars::Dollars(const double n) { d=(int)n ; c=100*(int(n)-d); } //a method for outputing an Dollars. ostream& operator<<(ostream& s, Dollars n) { if(n.d>=0) { s<<" $" << (n.d)<<"." << (n.c<10?"0":"") <0 ) return Dollars(d * b+cc/100, cc%100) ; else return Dollars(d * b+cc/100, ((-cc)%100) ) ; } Dollars Dollars::operator-() { return Dollars( - d, -c ); } //Overload the comparison operators int operator<(Dollars a, Dollars b) { if (a.d < b.d) return 1; else if (a.d == b.d) return a.c