编译错误:error: invalid initialization of non-const reference of type ‘*&’ from a temporary of type
2017-04-27 09:54
781 查看
属于函数参数引用临时变量错误
解决方案:函数声明和定义中在该参数的类型前添加const关键字。
例:void test_func(string &str);
将其改为:void test_func(const string &str);
在该函数实现中的对应位置做同样的改动。
解决方案:函数声明和定义中在该参数的类型前添加const关键字。
例:void test_func(string &str);
将其改为:void test_func(const string &str);
在该函数实现中的对应位置做同样的改动。
相关文章推荐
- error: invalid initialization of non-const reference of type ‘*&’ from a temporary of type
- C++之invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int’
- C++引用报错:invalid initialization of non-const reference of type ‘std::string&’ from an rvalue of type
- invalid initialization of non-const reference of type ‘xxx&’ from an rvalue of type ‘xxx’
- 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
- invalid initialization of non-const reference of type与discards qualifiers
- invalid initialization of non-const reference of type与discards qualifiers
- error: jump to case label与crosses initialization of"xx"编译错误
- 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' 声明改为包含头文件
- c++编译错误:invalid new-expression of abstract class type
- Android NDK编译错误处理-- error: undefined reference to '__dso_handle'
- 有关error:invalid type arguement of unary'*'(hava 'int')
- 在VC中使用switch语句时遇到“error C2360: initialization of 'k' is skipped by 'case' label”的编译错误。
- 运行时没问题 编译打包时出现 Error: Expected resource of type styleable [ResourceType] 错误
- Error: initial value of reference to non const must be lvalue 原因以及解决方法
- 错误:invalid use of non-static data member 'main_form::zhiliu_datainfo'
- error: jump to case label 或者 error: crosses initialization of 编译错误