I have a class for holding my Points
in 2D space like this:
class Point{
public:
Point(double a, double b){ x = a; y = b; }
//some additional information
private:
double x, y;
};
I like to have these Points
in a std::set
but I dont know how to write the compare struct
struct cCompare{
bool operator()(const Point &p1, const Point &p2){
//what should I write here??
}
};
Two Points like p
and q
are equal if (p_1,p_2) = (q_1,q_2)
. Do I have to store some additional information in my Point
class? Something like index or any unique number for each Point
? And have something like this:
struct cCompare{
bool operator()(const Point &p1, const Point &p2){
return (p1.index < p2.index);
}
};