If we have an integer, x, and an integer y, we can either say "take x and add y and store the result in z." This is written as
int z = x + y;
We can also say, "take integer x, add y and store the result in x." This is written as:
x += y;
(x = x + y)
So += would modify its left-hand variable, x, in this case.
Operator + does not modify its operands, since it returns a temporary.
Notice the "the result." This is the temporary part, which is the operation of adding x and y (but it isn't saving that anywhere!).
Yeah, we basically want to make a temporary object with the new string and return that....should I have
Since I'm not returning a pointer, but an object by value, I'm thinking the second approach is fine?
Thanks in advance for any help.
temp_obj is the temporary object we want to return, so no "wrapping" is necessary.
(If I followed this right.)