I'm trying to figure out if it is possible to overload the comparison operator for a member of an object. I know it is possible to overload the comparison of two objects, but what about the members specifically?
class Foo()
{
private:
int a;
int b;
int c;
char set
public:
void SetA();
int GetA();
void SetB();
int GetB();
}
Then lets say I wanted to compare a
specifically instead of the object as a whole:
int main()
{
Foo Ab;
Foo Bc;
Ab.SetA(1);
Bc.SetA(4);
int c {0};
if(Ab.GetA()>Bc.GetA())
{
c=5;
}
}
Instead of declaring an operator for the objects, is it possible to declare it for Get
methods?