wrote:
> A operator=(const B& ref)
> {
> printf("operator\n");
> return A();
> }
operator= should return a reference to "*this", not a new instance.
Else it doesn't make sense to return anything at all.
The semantics of '=' is that it's an expression which value is the
assigned value. If you return a new instance of A you are breaking
this semantic and thus returning anything at all makes no sense.(The
most typical case where this property is used is in expressions like
"a = b = c;" but there are other situations where the property can be
used as well.)
If you don't care about the return value of operator=, then it would
be cleaner to return void.