Why this is causing C2102: '&' requires l-value

前端 未结 5 1375
无人共我
无人共我 2021-01-02 12:16

I was wondering, why the following way of code (Already commented out) will cause
C2102: \'&\' requires l-value

Is there a better way to avoid u

5条回答
  •  甜味超标
    2021-01-02 12:56

    Because a::get_dummy() returns a unnamed temporary object (int pointer).
    Object returned by function sit ontop of the stack frame and it is meaningless to get its address since it might be invalid after expression ends.

提交回复
热议问题