If you declare any method that can pass for an assignment operator:
XXX Foo::operator=(Foo&);
XXX Foo::operator=(Foo const&);
XXX Foo::operator=(Foo volatile&);
XXX Foo::operator=(Foo const volatile&);
then the compiler will not generate the default version Foo& operator=(Foo const&);
.
Note that the return type is completely free, as for other methods. You could use void
, bool
, whatever really. It is just idiomatic (but not required) to return a reference to self in order to allow assignment chaining: a = b = c = 0;
which itself stems from the guideline that overloaded operators should follow the semantics of their built-in counterparts.