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
1. The descendant functionality is not available. I don't know who or how, but personally I never got access to SetRadius() and SetSide() from the Array.Maybe there's a way to solve the problem with autogenous, but I want to do without it.
2. Maybe I'm working incorrectly with pointers, but I either have a leak all the time or have to hit the pointers right in the block where the main work is done.
Can I give you an example?
It's just that the example I gave was taken from the documentation and it's not clear how it should work...
This is how it works. But completely out of documentation :/ (But once again I've practiced on pointers)
Execute:
can be done much more simply... virtualization:
That's not what I'm talking about. We're not talking about just using pointers, we're talking about an array of these pointers with a base class type.
It doesn't matter whether it's a simple array or an array of pointers, only what's written in the base class works and is available.
Or maybe I'm missing something.
For example, a slightly modified base class (designed as a structure)
If we cram all this stuff into the array, we'll get access to at least functionality declared in the base class.
The question is how to access functionality by descendant if the array is of base class type (i.e. array is of CShape type)?
that's not what I'm talking about. We're not talking about simply using pointers, but about an array of these pointers with a base class type.
The question is how to access the functionality by a descendant if the array is of base class type (i.e. the array is of CShape type)?I wrote on the last page how:
Same code, only with an array:
That's how it works. But completely off the documentation :/
Execute:
For something like this:
should be ripped off with the confiscation of the keyboard.
In C++ you can move through class hierarchy with dynamic_cast, and it is not liked there either. In MQL, it can cause implicit crashes that cannot be easily solved, because the bug is in a completely different place.
Therefore, I strongly advise against using this type of conversion. That is, at all. To ancestors please, to children ni.
For something like this:
You should take your hands off and have your keyboard confiscated.
In C++, you can move through class hierarchy using dynamic_cast, and it is not liked there either. In MQL it can cause implicit crashes that cannot be easily solved, because the bug is in a completely different place.
Therefore, I categorically advise against using such a conversion. That is, not at all. To ancestors please, not to children.
What's the polite way to answer....
If the programmer is too dumb, then a simple 1+1 operation can cause implicit crashes....
And I want to point out that MQL5 is not C++...
This is just a possibility, not a question of application....
Same code, only with an array:
1. Remove m_radius() from the ancestor, it's not in the example. :) And you will get no work with it in OnStart();
2. can the delete Base[0] line be moved somewhere else? Say, if it's not a script but an owl and I still need the data in the array.
I got memory leaks right away. I had to switch to structures for this reason...
1. Remove m_radius(), it is not present in the example. And get no work with it in OnStart();
2. may I move delete Base[0] line somewhere else? Say, if it's not a script but an owl, and I still need the data in the array.
I got a memory leak right away. I had to switch to structures for this reason...
1) Removed, it works:
2) The main thing is to delete it before the program ends... But if you have this pointer created in a function, you need to take care of saving it in a global location...