I changed the method getPrice(), insted using CopyClose() I'm using CopyBuffer(). This doesn't change the main objective.
So, if I use "const" keyword in the method getPrice(), a get the error: "'CopyBuffer' - no one of the overloads can be applied to the function call". I think this occurs because CopyBuffer is not a const method, and is not possible call non const method inside a const method.
You can drop thisObject and replace it by "this" in the comparison.
But, why dont you use the "operator" functionality instead of a function "Compare"? Makes the code easier to read later.
Because it's a polymorphic method of the base class CObject and it has to be overridden in order to implement sorting and searching in the Collection classes, CArrayObj and CList.
I'm not sure what you hope to achieve with this logic. Typically you would want to only compare the same elements for sorting and searching.
Exactly, now it is sorting, before that I could not make the comparison, I was getting erros and errors and errors. Now it's working.
This approach is not obvious and is not in any document, I had to do a lot of tests and "trial and error" until to get this. I hope others can enjoy the solution.
Exactly, now it is sorting, before that I could not make the comparison, I was getting erros and errors and errors. Now it's working.
This approach is not obvious and is not in any document, I had to do a lot of tests and "trial and error" until to get this. I hope others can enjoy the solution.
I am just curious why you needed the operator "&" in the function Compare() to get the value of "this".
Well, that does not answer the question "why". There was no reason to reveal the pointer to self.
No, definitely not in this example since it's a redundant extraction, but let's say you were passing this to a method that only accepted a pointer then you would need to use it... method(&this)
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hi @Alain Verleyen,
I changed the method getPrice(), insted using CopyClose() I'm using CopyBuffer(). This doesn't change the main objective.
So, if I use "const" keyword in the method getPrice(), a get the error: "'CopyBuffer' - no one of the overloads can be applied to the function call". I think this occurs because CopyBuffer is not a const method, and is not possible call non const method inside a const method.
Aparently, I solved the problema using the operator "&" in the function Compare() to get the value of "this":
Finally I got the value I was expecting.
You can drop thisObject and replace it by "this" in the comparison.
But, why dont you use the "operator" functionality instead of a function "Compare"? Makes the code easier to read later.
You can drop thisObject and replace it by "this" in the comparison.
But, why dont you use the "operator" functionality instead of a function "Compare"? Makes the code easier to read later.
Because it's a polymorphic method of the base class CObject and it has to be overridden in order to implement sorting and searching in the Collection classes, CArrayObj and CList.
Aparently, I solved the problema using the operator "&" in the function Compare() to get the value of "this":
Finally I got the value I was expecting.
I'm not sure what you hope to achieve with this logic. Typically you would want to only compare the same elements for sorting and searching.
I'm not sure what you hope to achieve with this logic. Typically you would want to only compare the same elements for sorting and searching.
Exactly, now it is sorting, before that I could not make the comparison, I was getting erros and errors and errors. Now it's working.
This approach is not obvious and is not in any document, I had to do a lot of tests and "trial and error" until to get this. I hope others can enjoy the solution.
Exactly, now it is sorting, before that I could not make the comparison, I was getting erros and errors and errors. Now it's working.
This approach is not obvious and is not in any document, I had to do a lot of tests and "trial and error" until to get this. I hope others can enjoy the solution.
I am just curious why you needed the operator "&" in the function Compare() to get the value of "this".
I am just curious why you needed the operator "&" in the function Compare() to get the value of "this".
It's the equivalent of using GetPointer(this)
Well, that does not answer the question "why". There was no reason to reveal the pointer to self.
Well, that does not answer the question "why". There was no reason to reveal the pointer to self.