If you want to define a method with which you can order a comparison of the set of objects of your class custome. For instance:
someClass instance1; someClass instance2;
You can do this by overloading the <operator for this class.
class someClass { bool operator<(someClass& other) const {
If you want to compare, and see if the objects are literally the same object, you can do a simple comparison of pointers to see if they point to the same object. I think your question is poorly worded, I'm not sure what you are going for.
EDIT:
For the second method, this is very easy. You need access to the location of your property. You can access this in many ways. Here are a few:
class someClass { bool operator==(someClass& other) const { if(this == &other) return true;
Note. I don't like the above, since usually == statements go deeper than just comparing pointers. Objects can represent objects of the same qualities without being the same, but this is an option. You can also do this.
someClass *instancePointer = new someClass(); someClass instanceVariable; someClass *instanceVariablePointer = &instanceVariable; instancePointer == instanceVariable;
It is insensitive and invalid / false. If it even compiled, depending on your flags, I hope you use flags that would not allow this!
instancePointer == &instanceVariable;
This is valid and will result in false.
instancePointer == instanceVaribalePointer;
This is also true and will lead to false.
instanceVariablePointer == &instanceVariable;
This is also true and will result in TRUE
instanceVariable == *instanceVariablePointer;
This will use the == operator, which we defined above, to get the result TRUE;