说明性语言
index out of range.
:下标越界
排序准则(sorting criterion)
或许因为不想,或许因为不能,无法使用一般的 operator<对这些对象排序,而是必须以某种特定的规则(通常基于某些成员函数)来排序,此时便是 function objects 施展身手的舞台;
class Person
{
public:
std::string firstname() const;
std::string secondname() const;
...
}
class PersonSortCriterion
{
public:
bool operator() (const Person& left, const Person& right) const
{
return left.lastname() < right.lastname() || (left.lastname() == right.lastname() && left.firstname() < right.firstname());
}
}