I have a function that compares objects by each attribute to see if they are identical. But I was just wondering, would it be better to compare the object by their address inste
I suppose that you make a proper distinction between same and equal.
Two pointers pointing to the same address means that they point to the same object. So yes: same address means same object and therefore equal (although equality makes sense only if we talk about more than 1 object).
Same attributes don't necessarily mean the same object. E.g. you can have two users with the same name "John Doe". The objects representing them would still be different objects, so they can't be used interchangeably. However, if you have a Point class, then two different instances of {1, 2}
really represent the same thing and can be used interchangeably.
There is a larger issue of difference between value objects and reference objects or entities, so I suggest to look it up.
E.g. if you have a Point class, then two different instances of {1, 2}
really represent the same thing, unlike the User example before.