MFC CString concatenation failure
Posted on 2008-10-14
If I have a local variable of type CString and then assign to it using the concatenation operator, things work fine:
one = "ONE";
two = "TWO";
x = StringFunction1() + StringFunction2();
However, if the second function is replaced by a member function of one of my classes,
x = StringFunction1() + myobject.StringFunction();
then no concatenation happens; the messagebox just shows "ONE".
I've looked on various google pages, and people keep saying you can't do this because you're returning a pointer to a local variable that no longer exists. Why ? Surely "return" has something like operator= semantics, in that it constructs a copy of whatever it is, in the callER's stack space ?