// Ilustration of class point parameterized with different policy types. // A bundle of (related) functions passed to Point (and all members of Point) at compile time. #include #include #include "point.cc" #include "norms.cc" templatevoid do_tell_about(C x, C y){ double dist = x.distance_to(y); std::cout << "Distance: " << dist << std::endl; std::cout << "Less than? " << (x.less_than(y) ? "true" : "false") << std::endl << std::endl; } int main(){ using namespace std; double dist; Point p1(1,2), // Here we parameterize p1 and p2 with a bundle of functions from Fixed form. p2(4,11); do_tell_about(p1,p2); Point p3(1,2), // Ditto p3 and p4 with HorizontalNorm p4(4,11); do_tell_about(p3,p4); Point p5(1,2), // Ditto p5 and p6 with VerticalNorm p6(4,11); do_tell_about(p5,p6); Point p7(1,2), // Ditto p7 and p8 with Norm p8(4,11); do_tell_about(p7,p8); }