   c++ operator overloading
  when overloading operators in c++, how many parameters do common operators take?for instance, to overload '+' for class Foo.a) Foo& operator+(const Foo &left, const Foo &right);orb) Foo& operator+(const Foo &right);and is there a good reference for how many parameters operators take?Thanks
Wikipedia's a good reference.It depends on whether the overload is a member of a class or a free-function. If it's a member then you ditch the left-hand-side argument (like your example b) as it's implicitly understood to be a reference to the object pointed at by the this pointer.   ;  exactly what I was lookin for, thanks.   ;Quote:Original post by godsenddeathfor instance, to overload '+' for class Foo.As you have already seen, you can implement binary + (as in a + b) with a binary free function or with a unary member function.Then there's also unary + (as in +a) which can be implemented with a unary free function or with a nullary (is that a word?) member function.   ;  I think game programming is hard.But it is an attrative job!   