Features of the mql5 language, subtleties and tricks - page 216

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
ZS: I've also seen macros like
I don't get it.
I don't get it.
there is a lot of information online about the convenience of such a macro, google "macro while 0"
https://russianblogs.com/article/9410298326/
There was an example of while(0) in this thread a long time ago
https://www.mql5.com/ru/forum/170952/page141#comment_12897922
To make it clear, it is only for static (this is all about C++). For local variables, if there is a user c-tor, there is no nulling.
I liked the explanation itself, which does not contradict OOP in any way.
When you create a simple structure object, the following happens:
When the declaration goes through {}, another one is inserted between items 1-2 - filling the allocated memory with zeroes.
With this logic, OOP does not suffer in any way. It is a valid mechanism.
When {} is declared, another one is inserted between points 1-2 - filling the allocated memory with zeros.
With this logic, OOP does not suffer in any way. Valid mechanism.
The logic suffers here: why do we need to zero it if there will be a constructor afterwards anyway?
The logic itself suffers here: why zero out if there will be a constructor afterwards anyway?
Because a structure with a constructor cannot be used in a union.
For union only initialize the first member, swap the fields and the test will run.
Let's think if it's worth to change behavior to become what most users expect.
Consider that I have changed - now I check the 1st term for x[i].i == 0 (before the condition was x[i].x == 0.0)
Result: false
And with ZeroMemory - true
there is a lot of information online about the convenience of such a macro, google "macro while 0"
https://russianblogs.com/article/9410298326/
All this mess is just to put a semicolon at the end of a macro. I use curly brackets in macros everywhere and have no problems.
Consider that I have changed - now I check the 1st term for x[i].i == 0 (previously the condition was x[i].x == 0.0)
Result: false
And with ZeroMemory - true.
Yes. mql bug
(and in C++ it returns true).