Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

classes c++

bigman2009
bigman2009 


i need help with assignment i have to make a class to make main.cpp work , main.cpp should be the same, because its instructor rule write the code i already made the class , see the uploaded file it has more info Attachments Tags
c++
Clarifications

Answers

Program Assignment (p3)

felo
felo 



find attached solution Attachments
prog03.zip (3 K) Download

Preview
overloaded - operator Money m5(3, 15, "money5"), m6(1, 99, "money6"); Money m7 = m5 - m6; cout << "Expected: 1 dollar 16 cents ... " << m7 << endl; // testing += operator m7 += m6; cout << "Expected: 3 dollars 15 cents ... " << m7 << endl; //

Preview
this->message = message; } string Memo::getMessage()

Preview
message); string getMessage() const; private:

Preview
*this = *temp; } int Money::getDollars() const { return dollars; } int Money::getCents() const { return cents; } Memo* Money::getPmemo() const { return pmemo; } Money& Money::operator=(const Money& right) {Money *temp = new Money(right.dollars,right.cents,(right.pmemo)->getMessage()); this->dollars = temp->dollars; this->cents = temp->cents; this->pmemo = temp->pmemo; return *this; } Money& Money::operator+=(const Money& right) {if (getPmemo() != NULL || right.getPmemo() != NULL)

Preview
Money(int dollars, int cents, string memo); int getDollars() const; int getCents() const; Memo* getPmemo() const; virtual ~Money(); // always declare destructor as VIRTUAL Money(const Money& right); // copy constructor, Memo object is copied // overloaded operators using member functions // implement the following ones by uncommenting them Money& operator=(const Money& right); //

Screenshots
Purchase Answer