Your solution does not return garbage if you have a working constructor - the String object is tmpcopied to the result object before it is destroyed at the end of the block.
You can do it better by replacing
String tmp;
tmp.Set(this->mString);
from
String tmp(*this);
(for this you need a properly working copy constructor, but you need it anyway for your operator return)
source
share