[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] [OT] C++ Question
- Subject: [ale] [OT] C++ Question
- From: jonathan.glass at ibb.gatech.edu (Jonathan Glass)
- Date: 02 Dec 2002 11:38:55 -0500
I'm working on my final project, and am having the hardest time with the
overloading the "+" operator for a custom class. Any thoughts? I'll be
happy to attach the full source file on request.
TIA
-----
CMoney CMoney::operator+ ( CMoney& t)
{
// money3 = money1 + money2
CMoney temp;
temp.m_cents= this->m_cents + t.m_cents;
return temp;
}
int main(int argc, char* argv[])
{
CMoney money1;
money1.AddMoney(0,101);
CMoney money2;
money2.AddMoney(0,100);
CMoney money3;
money3.ShowMoney();
money3=money1+money2;
cout << "MONEY1: ";
money1.ShowMoney();
cout << endl << "MONEY2: ";
money2.ShowMoney();
cout << endl;
cout << "MONEY3: ";
money3.ShowMoney();
return 0;
}
-----
Jonathan Glass
Systems Support Specialist II
Institute for Bioengineering & Bioscience
Georgia Institute of Technology
404.385.0127
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale