Overload of compare function not working

To add comments, please log in or register


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?


Jian Chen
Jian Chen  

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