From MQL5 Reference:
A method with the const
modifier is called constant and cannot modify implicit members of its
class. Declaration of constant functions of a class and constant
parameters is called const-correctness
control. Through this control you can be sure that the compiler will
ensure the consistency of values of objects and will return an error
during compilation if there is something wrong.
You can find more information in the Static members of a Class/Structure section.
Alexx:
Thanks for that, much appreciated.
From MQL5 Reference:
You can find more information in the Static members of a Class/Structure section.
And you can call this methods for const objects of this class type
class CFoo { public: void f() { }; void g() const { } }; void func(const CFoo &foo) { foo.f(); // error, cannot call non const method for const object foo.g(); // ok, g() is const method }

You are missing trading opportunities:
- Free trading apps
- 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
Hi all,
can anyone, please, explain what is the purpose of using the keyword 'const' in function definition? I have seen this in many places, for example in the CTrade class (see code snippet below) but the MQL5 language reference does not explain this at all.
Thanks in advance,
Rob.