You cannot overload operators for pointers, because they are primitive types (and you cannot create an overload where both arguments are primitive types); instead, you can overload the operators for your objects of user-defined types (not pointer to them):
class myClass
{
// ...
public:
bool operator>(const myClass & right) const
{
return this->whatever()>right.whatever();
}
};
myClass *a = new myClass(1);
myClass *b = new myClass(3);
if(*a > *b) //it should compare the int values from the constructors
//do something
notice that, if you don't have a particular reason to allocate stuff on the heap, it's much better to just allocate it on the stack:
myClass a(1);
myClass b(3);
if(a > b)
// do something
if (*a > *b)