I'm able to sort any three given coordinates with respect to their reference angle by overlaoding the < operator like so:
which is good, except there are special cases where this won't work. One of those cases is if two coordinates have the same reference angle.Code:// In coordinate class: bool operator<(const Coord& rhs){ return theta < rhs.theta; }; // And now in main or elsewhere I can say: coordList.sort();
My question is really what other operator can I overload to take care of this? Should I overload <=? ==?
Also, I've had problems trying to add if-else statements in overloaded operators, any idea why that is?
Like this:
Code:operator <(const Coord& rhs){ if(theta == something){ // do this } else{ // do something else } };