What about new operator? MQL vs C++
MyClass * p1 = new MyClass; //C++ MyClass * p1 = new MyClass(); // MQL5
What about new operator? MQL vs C++
creates an object pointer
not to be confused with a memory pointer
Perhaps you should read the manual.
How To Ask Questions The Smart Way. 2004
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.
In contrast to C++, the hobject variable from example above is not a pointer to memory, but rather an object descriptor.
Object Pointers - Data Types - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Related to the above, looking at the way dynamically allocated objects work in C++ it seems this is a point in which MQL5 and C++ differ.
See this example here from: https://www.educative.io/answers/what-is-the-arrow-operator-in-c-cpp
C++
#include <iostream> using namespace std; class Point { public: int x; int y; }; int main() { Point p1 = {10, 20}; // Regular object of class Point Point *p2 = &p1; // Pointer to p1 // Accessing members of p1 using the dot operator cout << "p1.x = " << p1.x << ", p1.y = " << p1.y << endl; // Accessing members of the object pointed by p2 using the arrow operator cout << "p2->x = " << p2->x << ", p2->y = " << p2->y << endl; return 0; }
For pointers to objects, like p2 in the snippet above, C++ uses the -> operator to access the object's class members: p2 -> x. However, in MQL5 it seems you would simply do p2.x, and it would work fine (?).
Can you confirm if this is indeed so?
Is this difference due to the fact that the MQL5 pointer is not a memory pointer, but an object "handle"?

Forum on trading, automated trading systems and testing trading strategies
Vladislav Boyko, 2024.05.05 13:51
It will be easier for you to understand if you read at least this:
Object-Oriented Programming (all subsections)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use