Sun May 25, 2008 5:44 pm
//So now you ask, what is this operator overloading stuff, how will it help
// me make the supreme burrito, and what the heck does "binary operator overloading"
//mean? Lets take this one step at a time. First, a quick example of operator overloading.
#include <iostream.h>
class Burrito
{
private:
int amtbeef, amtbean;
public:
Burrito(int beef, int bean) {
amtbeef = beef;
amtbean = bean;
}
Burrito operator + (Burrito newburrito)
{
int newbeef = amtbeef + newburrito.amtbeef;
int newbean = amtbean + newburrito.amtbean;
return Burrito(newbeef, newbean);
}
};
void main(void)
{
Burrito b1(5,10), b2(10,5), b3;
b3 = b1 + b2;
// cout<<b3<<endl;
}
Sun May 25, 2008 5:56 pm
Sun May 25, 2008 6:28 pm
Fri May 10, 2013 2:35 pm
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.