报错 error: invalid initialization of non-const reference of type ‘XXX &’ from an rvalue of type‘XXX‘

问题如图:  一般情况下,属于函数参数引用临时变量错误。 解决方案:函数声明和定义中在该参数的类型前添加const关键字。 例:void test_func(string &str); 将其改为:void test_func(const string &str); 在该函数实现中的对应位置做同样的改动。 然而,由于我的程序对应位置需要更改操作,所以不能加const限定。 于是,我把报错位置的引用&
相关文章
相关标签/搜索