Array of References or Pointers to Objects (Structs)

 

In the reference of MQL4 I find the basic DataTypes and I can define array of theses types but a reference or pointers to structs is not mentioned there.

Can I define an array of references to e.g. struckts and how should I do this?

An array of handles has to be defines as an array of int.

Gooly

 

I do not think so. It makes structure nearly useless for OOP. The predefined structures like MqlRates are very difficult to handle without pointers/references.

I convert them 1:1 to objects, despite it consumes resources and time.

Objects have no problem.

 
 
gooly:
I'll ask the service desk..
If you ask them "how", they will froward you here and/or give you a link to docs.
 

Well this works so far:

void OnStart()  {
//---
   struct TradeSet {
        string symb;// = "xxxYYY"; // GBPUSD   
   };
   TradeSet arr[3];
   int i;
   for(i=0;i<3;i++){
      arr[i].symb = "Test "+(string)i; 
   }
   string x;
   for(i=0;i<3;i++){
      x = x+"\n"+arr[i].symb;
   }
   Comment(x);
}

But I'd like to initialize the string-values but the compiler refuses this :(

 
Ovo:
If you ask them "how", they will froward you here and/or give you a link to docs.

Well in the ref is nothing about this way of using :(
 
gooly:

Well this works so far:

But I'd like to initialize the string-values but the compiler refuses this :(

I am not sure, what you mean by "initialize string-values". This?

   struct TradeSet {
      TradeSet() : symb("xxxYYY"){}
        string symb;// = "xxxYYY"; // GBPUSD   
   };

or

TradeSet arr[] = {{"x"},{"y"},{"z"}};
 

Normal variables I can initialize at their definition:

int x = 1;

And I would prefer to be able to do this as well:

 struct TradeSet {
        string symb = "xxxYYY"; // GBPUSD   
   };

But your way is the intention and may be the only way.

Gooly

Reason: