GetPointer of stand variable (not class)

SungSungE
163

I want to make sure variable live scope by check they use the same address.

Want print out address that indicate use the extern int XXX variable. and in EA int XXX variable.


GetPointer is use for class. IF some other ways I can do? Or some doc relative icustom indicator input/output data .

William Roeder
25836
William Roeder  
  1. 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.

  2. Don't double post! You already had this thread open.
              General rules and best pratices of the Forum. - General - MQL5 programming forum
SungSungE
163
SungSungE  

Ya Thanks. https://www.mql5.com/en/docs/common/getpointer

I think my question is about "confuse why MQL define this way? There is pointer for object, and struct use POINTER_AUTOMATIC

It's look like MQL  I guess there are some hiding thinking.Object has life scope issue. Struct don't have ,so for more easy to maintain ,just make it automatic.  
In the first month ,I thought pointer is always automatic , I don't need take care about it. After touch object new and delete. It's look like RD need define the life scope,ther is no garbage collection.


Only class objects have pointers. Instances of structures and simple-type variables can't have pointers. The class object not created using the new() operator, but, e.g., automatically created in the array of objects, still has a pointer. But this pointer will be of the automatic type POINTER_AUTOMATIC, therefore the delete() operator can't be applied to it. Aside from that, the type pointer doesn't differ from dynamic pointers of the POINTER_AUTOMATIC type.

Since variables of structure types and simple types do not have pointers, it's prohibited to apply the GetPointer() function to them. It's also prohibited to pass the pointer as a function argument. In all these cases the compiler will notify an error.

.




Documentation on MQL5: Language Basics / Data Types / Structures, Classes and Interfaces
Documentation on MQL5: Language Basics / Data Types / Structures, Classes and Interfaces
  • www.mql5.com
The structure name can't be used as an identifier (name of a variable or function). It should be noted that in MQL5 structure elements follow one another directly, without alignment. In C++ such an order is made to the compiler using the following instruction: If a structure contains variables of the string type and/or object of a dynamic...