C++ initial value of reference to non-const must be an lvalue

后端 未结 3 2046
逝去的感伤
逝去的感伤 2020-12-07 18:59

I\'m trying to send value into function using reference pointer but it gave me a completely non-obvious error to me

#include \"stdafx.h\"
#include 

        
3条回答
  •  半阙折子戏
    2020-12-07 19:27

    When you call test with &nKByte, the address-of operator creates a temporary value, and you can't normally have references to temporary values because they are, well, temporary.

    Either do not use a reference for the argument, or better yet don't use a pointer.

提交回复
热议问题