FIXED: call non-const method for constant object error after updating to build 3440
f.pap: This problem can be solved by renaming one of the two GetPtr() functions and explicitly calling the const or the non const version, showing that the compiler is no longer able to automatically discriminate between the two.
Is this a bug of the new build?
There was no way to "discriminate between the two". It should have been caught and not compiled previously.
It is a bug, as it could not have compiled.
William Roeder #:
There was no way to "discriminate between the two". It should have been caught and not compiled previously.
It is a bug, as it could not have compiled.
Actually, there IS a way to discriminate between the two: the compiler chooses the const overload when the function is called on a const object (or via a reference or pointer to const), it chooses the other overload otherwise.
So the compiler uses the const version of the CA::GetPtr() function with the CB::Get() and the non const version with the CB::Set().
Defining two versions const / non const of the same function, especially the ones returning pointers, is usual practice in other languages, like C++. This also worked perfectly with the previous builds of MT5, because the compiler was able to correctly choose the right version of the function to use, as my script (compiled with build 3325) shows through the strings that are printed and that can be seen in my previous message.
This is the reason why I think that this limitation to function overloading was inadvertently added to the latest build and, in this hypothesis, is to be considered a bug of the latest build.
Just to inform that this problem has now been fixed, at least in build 3800 but maybe even before.

You are missing trading opportunities:
- Free trading apps
- Free Forex VPS for 24 hours
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I have found a problem in some code that compiled correctly before updating to build 3440.
I have simplified the problem to these few lines of code:
The error I get is the following:
This code compiles perfectly on an older release, for example with build 3325, and, launching this script on a EURUSD chart, I obtain:
demonstrating that it calls the right version (const / non const) of the GetPtr() function.
This problem can be solved by renaming one of the two GetPtr() functions and explicitly calling the const or the non const version, showing that the compiler is no longer able to automatically discriminate between the two.
Is this a bug of the new build?
Thank you for your help.