error: invalid initialization of non-const reference of type ‘*&’ from a temporary of type
2017-10-30 09:59
525 查看
属于函数参数引用临时变量错误
解决方案:函数声明和定义中在该参数的类型前添加const关键字。
例:void test_func(string &str);
将其改为:void test_func(const string &str);
在该函数实现中的对应位置做同样的改动。
解决方案:函数声明和定义中在该参数的类型前添加const关键字。
例:void test_func(string &str);
将其改为:void test_func(const string &str);
在该函数实现中的对应位置做同样的改动。
相关文章推荐
- invalid initialization of non-const reference of type ‘int*&’ from a temporary of type ‘int*’
- invalid initialization of non-const reference of type ‘int*&’ from a temporary of type ‘int*’
- C++引用报错:invalid initialization of non-const reference of type ‘std::string&’ from an rvalue of type
- C++之invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int’
- invalid initialization of non-const reference of type ‘xxx&’ from an rvalue of type ‘xxx’
- 编译错误:error: invalid initialization of non-const reference of type ‘*&’ from a temporary of type
- C++引用报错:invalid initialization of non-const reference of type ‘std::string&’ from an rvalue of type
- invalid initialization of non-const reference of type与discards qualifiers
- invalid initialization of non-const reference of type与discards qualifiers
- ***stm32f10x_type.h(23): error: #256: invalid redeclaration of type name "s32" 原因+解决方案
- Error: initial value of reference to non const must be lvalue 原因以及解决方法
- error: request for member '*' in '*', which is of non-class type '*'
- A const field of a reference type other than string can only be initialized with null Error [duplicate]
- initialization discards 'const' qualifier from pointer target type
- C++ Error : initial value of reference to non-const must be an lvalue
- error: invalid use of incomplete type 'XXXX' ;error: forward declaration of 'XXXX' 声明改为包含头文件
- 有关error:invalid type arguement of unary'*'(hava 'int')
- warning C4047: 'initializing' : 'char *' differs in levels of indirection from 'const int '
- java.lang.VerifyError: Bad <init> method call from inside of a branch
- invalid conversion from 'const char*' to char*