#include <iostream>
#include <stdlib.h>
using namespace std;
class Point2D {
public:
float x, y;
Point2D():x(0),y(0){};
Point2D(float x, float y):x(x),y(y) {};
float getX()const{return x;};
float getY()const{return y;};
friend ostream &operator<<(ostream &os, const Point2D &p) { os<<"("<<p.getX()<<", "<<p.getY()<<")"; return os;};
};
class LeftRight { // a left-right comparator
public:
LeftRight(){};
bool operator()(const Point2D& p, const Point2D& q) const
{ return p.getX() < q.getX(); }
};
class BottomTop { // a bottom-top comparator
public:
BottomTop(){};
bool operator()(const Point2D& p, const Point2D& q) const
{ return p.getY() < q.getY(); }
};
template <typename E, typename C> // element type and comparator
void printSmaller(const E& p, const E& q, const C& isLess) {
cout << (isLess
(p, q
) ? p
: q
) << endl
; // print the smaller of p and q }
/**/
int main() {
Point2D p(1.3, 5.7), q(2.5, 0.6); // two points
//cout<<p.getX();
LeftRight leftRight; // a left-right comparator
BottomTop bottomTop; // a bottom-top comparator
//cout<<leftRight(p,q)<<endl;
//cout<<bottomTop(p,q)<<endl;
printSmaller<Point2D, LeftRight>(p, q, leftRight); // outputs: (1.3, 5.7)
printSmaller<>(p, q, bottomTop); // outputs: (2.5, 0.6)
/**/
return 0;
}