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
Also, this is wrong - there is a 'final' keyword in MQL5.
{
//--- class body
};
class CBar : public CFoo
{
//--- class body
};
this will not let CBar compile because CFoo is final.
You are wrong here, whroeder1.
Not adding virtual in the base will cause you loosing the polymorphism - the method will be called statically and not dynamically at run time.
This was the caveat that whroeder1 mentioned.
Also, this is wrong - there is a 'final' keyword in MQL5.
1. It is not only bad practice, but required in every base (not only in CObject) if polymorphism is required.
2. It does change things - see 1.
3. final does exist.
There is also a final keyword in MQL4, although the documentation doesn't show it (to my knowledge). Possibly it was mentioned in a build update.
Correct!
It was Build 1430 for MQL5. Probably around the same time for MQL4 with the common compiler.
Hi guys,
I'm working in a class exactly like this post, but my "score" variable is a method. How to get its value?
This is the code from the begining of the post:
This is what I'm trying to do:
The question is, how to use getPrice() inside the method Compare()?
ThanksHi guys,
I'm working in a class exactly like this post, but my "score" variable is a method. How to get its value?
This is the code from the begining of the post:
This is what I'm trying to do:
The question is, how to use getPrice() inside the method Compare()?
ThanksDeclare your getPrice() method with const keyword.
Declare your getPrice() method with const keyword.
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.