且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何排序使用排序功能在C ++中二维数组?

更新时间: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).