looking for confirmation ..

 

Hi,

am I right that we cannot have this kind of pointer structure?

struct _S{
   int i;
};
_S p, arr[];
ArrayResize(arr,5);
p = &arr[2]; // compiler error: '&' - operand expected  test_OrderArrray.mq4    

Is there another way than using a function (that requires calls by reference)?

 
  1. p is a single _S; it is not a pointer. arr is an dynamic array of _S.
  2. &arr[2] is what you do in C++ create a pointer; taking the address of arr[2]. MQL4 doesn't have pointers (except to classes.)
  3. What are you trying to do?
 
WHRoeder:
  1. p is a single _S; it is not a pointer. arr is an dynamic array of _S.
  2. &arr[2] is what you do in C++ create a pointer; taking the address of arr[2]. MQL4 doesn't have pointers (except to classes.)
  3. What are you trying to do?

add 3) I would like to have a simple access to complex structures.

add 2) I had the suspicion there are no pointers in MQl4 except to classes AND except to function calls! So I tried whether this might already (b+600) has been changed and someone has found that hidden feature.

add 1) I know, but I tried to use something others might understand what I'd like to have - due to MQL4's function calls with arrays, structs, ...

 
You can only have pointers to classes as Structures and Classes - MQL4 Documentation says
the new operator can be applied to class objects; this operator cannot be applied to structures;
Function calls are irrelevant.
class T{
 public: 
  int v;
};
void OnStart()
  {
  T arr[3]; 
  for(int i=0; i < 3; ++i){
    arr[i].v = i;
    T* p = GetPointer(arr[i]);
    Print(p.v); // 0, 1, 2
  } 
Reason: