I have two different classes for two different robots. I am trying to overload the == operator to compare if the location is the same for both. Can anyone help me?
Asked
Active
Viewed 33 times
0
-
1Refer to [how to ask](https://stackoverflow.com/help/how-to-ask) where the first step is to *"search and then research"* and you'll find plenty of related SO posts for this. – Jason Oct 18 '22 at 11:54
-
1What have you got already? Do you really want `robot1 == robot2`, and not e.g. `are_same_location(robot1, robot2)` or `robot1.location == robot2.location`? – Caleth Oct 18 '22 at 11:55
-
**Stack Overflow is not a coding service for ordering code.** Refer to [how to ask](https://stackoverflow.com/help/how-to-ask) and take a [SO tour](https://stackoverflow.com/tour). Show us what you've tried so far and what problem you're facing with that so that we can find out the problem and suggest a correction(if any) and maybe even provide a better solution. – Jason Oct 18 '22 at 11:55
-
Why would you want two different robots, if they happen to be at the same location, to compare equal? As an example of why you probably would NOT want to do that, assume that a robot's location is the coordinates of its centre of mass and consider basic physics - two distinct objects can have the same centre of mass. – Peter Oct 18 '22 at 13:04