//Excerpt from visionary.C. class closest_enemy_to { const wabbit *const w; public: closest_enemy_to(const wabbit* initial_w): w(initial_w) {} //Return true if w1 is a closer enemy of w than w2 is. bool operator()(const wabbit *w1, const wabbit *w2) const { //If w1 is not an enemy of w, return false. if (w1 == w || w1->hungry() <= w->bitter()) { return false; } //Arrive here if w1 is an enemy of w. //If w2 is not an enemy of w, return true. if (w2 == w || w2->hungry() <= w->bitter()) { return true; } //Arrive here if w1 and w2 are both enemies of w. return distance(w1, w) < distance(w2, w); } };