In C++, binary operators can either be overriden with one or two operators, when the LHS is the class being declared. If declared with two parameters in must be a non-member function. Vis in this code, the two declarations are identical.
class MyClass
{
public:
MyClass operator+(const MyClass&);
}
MyClass operator+(const MyClass&, const MyClass&);
Is there a reason the latter can not be done as a static member function? Like this
class MyClass
{
public:
static MyClass operator+(const MyClass&, const MyClass&);
}
It would make writing the stream in/out operators easier (I am aware you can use friend to declare the operator)