Orphious
12-10-01, 04:53 PM
I'm doing something wrong here is I usually am doing :D. Perhaps we can find it. I want to overload == to compare two objects.
The values are const refernce params, and the function should return one of the bool values true or false. They're suppost to be nonmember functions. Now its in a
class Rock
the basic function overload would look like this(I think?!?)
bool operator==(const Rock &x, const Rock &y)
{
if (x==y)
return true;
else
return false;
}
Now what would I have to do here to make it a nonmember function?
would making it a friend make it nonmember?
O, and its tested like this
cout << "rock1 == rock2? " << (rock1 == rock2 ? "Yes" : "No") << endl;
Thanks guys, sorry if that looks messy
The values are const refernce params, and the function should return one of the bool values true or false. They're suppost to be nonmember functions. Now its in a
class Rock
the basic function overload would look like this(I think?!?)
bool operator==(const Rock &x, const Rock &y)
{
if (x==y)
return true;
else
return false;
}
Now what would I have to do here to make it a nonmember function?
would making it a friend make it nonmember?
O, and its tested like this
cout << "rock1 == rock2? " << (rock1 == rock2 ? "Yes" : "No") << endl;
Thanks guys, sorry if that looks messy