// Four different Point policies - the static methods are now specific to class Point. // This file does not have any template classes nor template functions. #include #include "Point.h" struct FixedNorm{ static bool less_than(const Point& a, const Point& b){ return false; } static double distance_to(const Point& a, const Point& b){ return 7.0; } }; struct HorizontalNorm{ static bool less_than(const Point& a, const Point& b){ return a.getx() < b.getx(); } static double distance_to(const Point& a, const Point& b){ return fabs(a.getx() - b.getx()); } }; struct VerticalNorm{ static bool less_than(const Point& a, const Point& b){ return a.gety() < b.gety(); } static double distance_to(const Point& a, const Point& b){ return fabs(a.gety() - b.gety()); } }; templatedouble square(T a){ return a*a; } struct Norm{ static bool less_than(const Point& a, const Point& b){ return (a.getx() < b.getx()) && (a.gety() < b.gety()); } static double distance_to(const Point& a, const Point& b){ return sqrt(square(a.getx() - b.getx()) + square(a.gety() - b.gety())); } };