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

后端 未结 3 2039
逝去的感伤
逝去的感伤 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:18

    The &nKByte creates a temporary value, which cannot be bound to a reference to non-const.

    You could change void test(float *&x) to void test(float * const &x) or you could just drop the pointer altogether and use void test(float &x); /*...*/ test(nKByte);.

提交回复
热议问题