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
If the structure has one field, that's fine. If there is more, it is pointless and even stupid.
Who would want a single-field structure? How does this "structure" help?
Who would want a single-field structure? How does this "structuring" help?
structure wrapper over an array
MQL can't handle pointers, but it can handle structures without constraints, so you have to wrap an array in a structure
structure wrapper over an array
MQL can't handle pointers, but it can handle structures without any limitations, so we have to wrap an array into a structure
Wouldn't it be easier to wrap it in a class? Still, the structure is, first of all, an advantage when working with a static data list. Also, when working with a dynamic structure, it's not convenient to land it later.
Wouldn't it be easier to wrap it up in a class? A structure is primarily an advantage when working with a static list of data. And when you work with a dynamic structure, it's not convenient to land it.
it's simpler at
And to avoid multiplication of types, I made a class that describes the public section of the structure, using these types partially outside the class,
use them as normal structures, the only thing is more colons, but I won't say it bothers me
Who would want a single-field structure? How does this "structure" help?
That was a... what's-his-name... rhetorical thesis))
However, sometimes it may be useful to put one array into a structure and then use an array from these structures.
It works fine. There is just one thing. When the structure is returned from the function, it is not the structure created inside the function, but a copy of this structure, that is, the implicit copy constructor is launched.
There is no unnecessary copying, the structure is created in the stack and the required field is copied from it.
This is if the compiler co-optimises. Otherwise, when f() is called, the following will happen. The stack node pointer is shifted to the size of the structure (this is where the result will be returned). The function code goes up on the stack. Further, in the process of execution we get to the declaration of the structure. The stack pointer again shifts to its size. It is this structure that is filled with the function. Before the function exits, the memory allocated for the structure in the function is copied into the memory allocated for the return.