【发布时间】:2020-01-16 09:08:57
【问题描述】:
我的代码如下:
void parentheses (int n, string& str, int left, int right){
... irrelevant...
}
void solve(int n){
parentheses(n,"",0,0);
}
但是,这会给我一个错误,告诉我cannot bind non-const lvalue reference of type std::__cxx11::string& ... to an rvalue of type ‘std::__cxx11::string。在这种情况下,如果我仍然想将字符串作为参考传递,我应该如何修改我的函数?我不想让它们成为const,因为我想要修改原始字符串的函数,我希望它们成为&,正是因为我想编辑它们的值。
【问题讨论】:
标签: c++ reference lvalue ampersand