我有这个代码:
struct PointComparator
{
explicit PointComparator(const Point& lowest)
: m_lowest(lowest)
{}
bool operator()(const Point& a, const Point& b)
{
std::cout << m_lowest[0] << std::endl;
return; // TODO
}
private:
Point m_lowest;
};
// in another function:
Point lowestPoint; // (get this from somewhere)
std::sort(points.begin(), points.end(), PointComparator(lowestPoint));
我只是搞不懂显式关键字。当我执行正常排序时,我会调用
当我执行正常排序时,我会调用
实际上,没有。传递给
当你写到:
std::sort(points.begin(), points.end(), PointComparator(lowestPoint));
这或多或少与
PointComparator compare(lowestPoint);
std::sort(points.begin(), points.end(), compare);
这里的