how to refer to the current struct in an overloaded operator?
- by genesys
Hi!
I have a struct for which i want to define a relative order by defining < , , <= and = operators. actually in my order there won't be any equality, so if one struct is not smaller than another, it's automatically larger.
I defined the first operator like this:
struct MyStruct{
...
...
bool operator < (const MyStruct &b) const {return (somefancycomputation);}
};
now i'd like to define the other operators based on this operator, such that <= will return the same as < and the other two will simply return the oposite.
so for example for the operator i'd like to write something like
bool operator > (const MyStruct &b) const {return !(self<b);}
but i don't know how to refere to this 'self' since i can refere only to the fields inside the current struct.
whole is in C++
hope my question was understandable :)
thank you for the help!