更新时间:2023-12-06 15:32:10
由于比较函数不应该修改其参数,你必须以这样的方式来创建你比较它接受常量引用:
Since comparator functions aren't supposed to modify their arguments, you have to create your comparator in such a way that it accepts const references:
bool compare(const vector<int> &a, const vector<int>& b)
这是显而易见的。
invalid initialization of reference of type 'std::vector<int>&' from expression of type 'const std::vector<int>
该错误消息的一部分(你可以不通过常量
对象非 - 常量
函数的参数)。
part of the error message (you can't pass a const
object to a non-const
function argument).