How to overloading the less/more operator ?

 
struct TickOne
{
datetime time;
double ask;
double bid;

bool operator>(const TickOne &r) { return this.ask>r.ask; }
bool operator<(const TickOne &r) { return this.ask<r.ask; }
};


I want to compare two custom objects by using the (<,>) less/more operator.

For example:

A tickOne, tickOne2 objects are created from the TickOne class. This tickOne is needed to be compare with the tickOne2 object. It should be compare by the ask field.

My code have some problem. When these two objects are compare, compiler show the error: '>' - illegal operation use / <' - illegal operation use

What does wrong with the code ?


 
jhliguktxikdtxf: What does wrong with the code ?

There is nothing wrong with your posted code — it compiles fine. Your problem is elsewhere.