[ale] [OT] C++ Question
Jonathan Glass
jonathan.glass at ibb.gatech.edu
Mon Dec 2 11:38:55 EST 2002
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
More information about the Ale
mailing list