- #36
- 5,657
- 230
Both function return temp object and copy into L3. The function ended and destroyed, but the temp is being returned back.......
The first version returns a reference to a local variable (a variable that is declared insideoperator+()
). What happens to local variables afteroperator+()
finishes and you return tomain()
, or to whatever function calledoperator+()
?