I’m trying something like this:
Foo & operator=(Foo & to, const Bar &from);
But I’m getting this error:
E2239 'operator =(Foo &, const Bar &)' must be a member function
Are there limitations on which operators can/cannot be defined as Free Functions, and if so, why?
The assignment operator must be a non-static member function and must have exactly one parameter:
operator(),operator[], andoperator->must also be implemented as non-static member functions.Class-specific
operator newandoperator delete(and variants thereof) must be implemented as static member functions (note that these are implicitly static, even if they are not declared with thestatickeyword).