C++ Operator overload: stl sort on vector of my custom class
c++, operator-overloading, sorting, stl, vector
Solution
`bool operator< (``const``Point &p1,``const``Point &p2 )`
Problem
I have a very basic class that is stored inside an STL Vector. I am trying to sort that vector, but am getting cryptic STL errors. Can someone assist? ``` // Point.h class Point { public: Point() : x(0), y(0) {} Point( float x0, float y0 ) : x(x0), y(y0) {} float x; float y; }; // Point.cpp, updated const as per given answers bool operator< (const Point &p1,const Point &p2) { return p1.x < p2.x || (p1.x==p2.x && p1.y< p2.y); } ``` Again, this Point class is stored in a vector and is being sorted: ``` std::vector<Point> tmp=N->points; std::sort(tmp.begin(),tmp.end()); ``` Errors: http://ideone.com/WIv0u Can someone point me in the right direction? Thanks!