Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1335
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
There shouldn't be any difference. It just looks nicer to me - the code is less loaded with parentheses and indents.
For one check (if) yes, but in code there are two, and if there are many, then logic If Yes, contingency and new loop iteration, Otherwise action A logic If No then action otherwise pass to next condition If No. In this case, the body of the loop will go all the way through.
For one check (if) yes, but there are two in the code, and if there are many, then the logic If Yes, continue and a new loop iteration, Otherwise action A logic If No then action otherwise pass to the next condition If No. In this case, the loop body will go through to the end.
I don't understand anything, but let it be so.
They will. I use it because I want to :) This explicitly specifies which class methods are used.
If you have two classes, one as parent and one as an inherited class, and they have two methods with the same name, but they are not virtual for some reason, you have to explicitly specify which method to use.
Suppose parent class is CParent and inherited class is CInheritedand they both have Method() method.
In this case, if we call a method Method() of a CParent class, it will explicitly call a method of the CParent class - this is not required here. We can call the method with or without it.
If wecall aMethod() method in an inherited CInherited class, the methodof that class will also be called, since we first look for a method belonging to the class we called it from.
If wecall CParent::Method() in a CInherited class, it is the method of the parent class that will be called this way, because we have explicitly specified a method that belongs to the parent class by context resolution operator.
But still I would call method Method() in CInherited class withindication this - to be sure that method of this (this == "this") inherited class will be called.
There are other explanations for using this. Maybe someone more experienced in OOP can tell us.
Artem, thank you very much for such a comprehensive answer, which changes the attitude to OOP for the better).
How do I open a live account?
1. Choose a broker.
2. Choose a platform, MT4 or MT5.
3. Open a live account with the broker.
Well, yes. I'm one of those "some people", especially when I call a standard function from a class, I make sure to specify the global context. Just because I can think of adding a method in that class with the same name as the standard function - so I'll never forget what it does. And that's when you need :: to call a standard function, and this - to call my method with the same name.
Artem, it already disproves the second part of expression "necessary - not necessary". It is necessary, means it is necessary. There is no objection...
Hello
How to calculate the distance in pips from the current price to the nearest limitpending order. I'm interested in a ready-made code.
For one check (if) yes, but there are two in the code, and if there are many, then the logic If Yes, continue and a new loop iteration, Otherwise action A logic If No then action otherwise pass to the next condition If No. In this case the body of the loop will go all the way through.
For me, the preferred option is
or this
Another variant
The other variant is on the verge of idiocy.
But this is a matter of taste. Whichever one likes.
As far as I understand, this way was used when the if operator checked ALL the conditions from the beginning to the end. It was justified by the fact that if the first condition is not fulfilled, you will not have to check the following conditions. Now all the conditions after the one that was not fulfilled are not checked. And such condition staircases are no longer necessary, only a habit is left.
Artyom, that already disproves the second part of the "should-don't" expression. If I have to do it, I have to do it. No objection...