T
toton
Hi,
I have a struct Point { int x, int y; }
The points are stored in a std::vector<Point> points; (global vector)
I want to add equality (operator == ) for the point, which will check
equality based on the position of the point in the vector rather than
its x,y or any other criterion. Thus 2 free point (which are not in
the vector are always unequal ) and so on.
How to add this kind of equality operator ? Is comparing memory
location like this is ok ?
bool operator==(const point& p1,const point& p2){
return &p1 == &p2;
}
I have a struct Point { int x, int y; }
The points are stored in a std::vector<Point> points; (global vector)
I want to add equality (operator == ) for the point, which will check
equality based on the position of the point in the vector rather than
its x,y or any other criterion. Thus 2 free point (which are not in
the vector are always unequal ) and so on.
How to add this kind of equality operator ? Is comparing memory
location like this is ok ?
bool operator==(const point& p1,const point& p2){
return &p1 == &p2;
}