temp variable lifetime

Started by
11 comments, last by nullsquared 18 years, 7 months ago
Quote:O ,I see, but why return value can not be l value?


Because that's what the standard says. A function call evaluates to an r-value unless the function is declared as a reference type. Now, I'm not sure why you would want to do what it appears you are doing (other than for tinkering purposes) but you might try it this way:

int& get(int ii){int i = ii;return i;}int bar(int *i){return *i;}int i11 = bar(&get(4));

Advertisement
Thanks everyone. you are sweet.
Huh?? int *pReturn(){int *point = new int(1); return point;} <<should work fine as long as you assign another pointer to the returned address.

This topic is closed to new replies.

Advertisement