Descriptor vs. pointer in MQL5 - question to MetaQuotes
MetaQuotes: is it a secret or what? No-one has replied this question for 5 days. I guess that as you are the creators of the MQL5 language, you could easily tell the reason behind such approach.
Enigma71fx:
Just for safe reason.MetaQuotes: could you please give some insight on it? Why is this difference (in comparison to C++) introduced?
Rosh:
Just for safe reason.
What kind of safe reason? E.g. to avoid situation, in which pointer could point to a wrong place in memory? Sorry for bothering you, but I am asking out of curiosity.
Just for safe reason.
Enigma71fx:
What kind of safe reason? E.g. to avoid situation, in which pointer could point to a wrong place in memory?
Yes, you are right.What kind of safe reason? E.g. to avoid situation, in which pointer could point to a wrong place in memory?
Rosh:
Yes, you are right.
Yes, you are right.
That's what I supposed. Thanks, Rosh! Forum users can always count on you :)
By the way - as you have appeared on the forum - may I ask you for a comment on a different thread, related to declaring static class members? -> https://www.mql5.com/en/forum/1395 This seems like a major drawback, comparing to C++. It is really difficult and uncomfortable to implement some OOP techniques without it.
Hi,
While browsing MQL5 reference, I have found such description in the section MQL5 Reference / Language Basics / Data Types / Object Pointers:
Object Pointers
In MQL5, there is a possibility to dynamically create objects of complex type. This is done by the new operator, which returns a descriptor of the created object. Descriptor is 8 bytes large. Syntactically, object descriptors in MQL5 are similar to pointers in C++.
Examples:
MyObject* hobject= new MyObject();
Again, unlike C++, the variable hobject from the example above is not a pointer to the memory, it is a descriptor of the object.
MetaQuotes: could you please give some insight on it? Why is this difference (in comparison to C++) introduced?