/** returns distance from this city to another one (dest_city), calculated from these cities coordinates */ Distance distance(const City &dest_city) const { Coord dx = getX() - dest_city.getX(); Coord dy = getY() - dest_city.getY(); return sqrt(static_cast<double>(dx*dx + dy*dy)); }
double distanceTo(City& from, City& to) { int xd = from.getX() - to.getX(); int yd = from.getY() - to.getY(); return sqrt(xd * xd + yd * yd); }