MQL5 The compiler does not distinguish between a class and a pointer to it - page 7
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
So you're proposing to ban implicit naming of pointers altogether? I don't think many people here would be happy about that.
Let everyone have a choice.
I certainly don't want that kind of trick.
Well, that goes without saying. There's a memory leak.
A memory leak, you say? How about this? )))
A memory leak, you say? How about this? )))
delete item;
So it assumes that the subject is prepared to be treated that way. How many foresee this possibility?
So this assumes that the object is prepared to be treated in this way. Do many people provide for such a possibility?
I think that if someone writes the word new, they should know exactly where the corresponding word delete is located elsewhere in their code.
Let everyone have a choice.
I certainly don't need such tricks.
I already use it in MQL4. How will it work then, if language syntax is the same?
Well, as a protection against such actions one can create a private method in a class:
Although, frankly, I don't see a problem here. If you assign something to a class object, you a priori expect that the copy operator will be called. You want it, you get it. What difference does it make if there was a pointer or an object? The class type is the same. You can't assign any left-handed class. That's why it all looks more like an idle bore.
The opposite case, with the pointer on the left, is another matter. There you could have expected to assign something to the pointer, but it turned out to be copying an object.
The opposite case, with the pointer on the left, is different. There you might expect to assign something to the pointer, but it turns out you're copying an object.
And you can't forbid this, otherwise you won't be able to copy the object when you really need to.
As a result, you have to leave everything as it is. Just be aware of what you are doing.
And you can't forbid it, otherwise you won't be able to copy the object when you really need to.
In the end, you have to leave it as it is. Just be aware of what you're doing.
О! That's the main thing.
Are there many people here who know how to navigate the modes of memory management? Understanding the difference between AUTOMATIC and DYNAMIC.
And have heard something about STATIC and BASED (although this is not necessary).
And you can't forbid it, otherwise you won't be able to copy the object when you really need to.
In the end, you have to leave it as it is. Just be aware of what you are doing.
Why can't it work? There are * and & operators to reduce it to what is required.
Where is there a *?