Download MetaTrader 5

Overload of compare function not working

To add comments, please log in or register
Create Forum topics and improve your rating!
gbulle
127
gbulle 2015.06.06 13:17 

Hello,

time ago I downloaded from MQL4 the attached sample and it was working fine.

The sample generates a list and sorts it using different criteria.

The sample overloads COMPARE function to generate  custom sorting.

Now the overload  is not more working and the sample uses the base class sort.

I put a PRINT ("SORT") statement into compare  function and I do not see the print in the experts tab after the SORT.


Can someone help me?

Thanks

Files:
Jian Chen
Moderator
3621
Jian Chen 2015.06.07 03:07  

If the code worked before and it is not working now, maybe the declaration of CObject::Compare() function was changed.

As a virtual function, you need to declare the CMyListElement::Compare() function exactly as the "CObject::Compare()" function.

In Line 50, change the code to:

virtual int       Compare(const CObject *object,const int mode=0)const;

 You'll also need to do the same change at the function's implementation.

I already tested the code on my computer, it is working fine now :) 

To add comments, please log in or register