[ale] [OT] C++ Question

Jim Popovitch jimpop at rocketship.com
Mon Dec 2 11:46:18 EST 2002


Hi Jonathan,

This should help... if not what specific error are you getting?

http://hpcf.nersc.gov/vendor_docs/ibm/vac/language/ref/overloading.cplr318.h
tm


-Jim P.

> -----Original Message-----
> From: ale-admin at ale.org [mailto:ale-admin at ale.org]On Behalf Of Jonathan
> Glass
> Sent: Monday, December 02, 2002 11:39 AM
> To: ale at ale.org
> Subject: [ale] [OT] C++ Question
>
>
> 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
>


_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale






More information about the Ale mailing list