MQL5 pointer vs C++ pointer

 
What is the difference between MQL5 pointer and C++ pointer?
 
MTx does not have pointers! It only has handles to class objects. GetPointer returns a handle. You can not get a pointer to POD. You can not increment a handle to point to the next array element.
 

What about new operator?  MQL vs C++

MyClass * p1 = new MyClass;   //C++
MyClass * p1 = new MyClass(); // MQL5
 
Overweight:

What about new operator?  MQL vs C++

creates an object pointer 

not to be confused with a memory pointer 

 
Overweight: What about new operator?  MQL vs C++

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"?

What is the arrow operator (—>) in C/C++?
What is the arrow operator (—>) in C/C++?
  • www.educative.io
Contributor: M. Saddam Khalil
 
Juan Guirao #: Can you confirm if this is indeed so?

Why can't you try it in the debugger?