struct undeclared identifier

 

Hi

This mql5 code gives a compile time error: "abc undeclared identifier", any idea why and how to fix it?

Thanks


//myfile.mqh

struct abc {
 ushort aa;
 double bb;
 string cc;
};

class AB {
 private:
  abc abcArr[3];    

 void doStuff(){
  abc x;             //<<<< compile time error - undeclared idntifier abc,  why?
  x.aa = 4;
  x.bb = 2.3;
  x.cc = "AUD";
  abc.Add(x);

 }
};
 
samjesse:

Hi

This mql5 code gives a compile time error: "abc undeclared identifier", any idea why and how to fix it?

Thanks


hmm... when i compile, i only get ['.' - name expected] for this line:

  abc.Add(x);

and if i comment out this line, everything else compiled without error... are we using a different compiler? LOL

 
Seng Joo Thio:

hmm... when i compile, i only get ['.' - name expected] for this line:

and if i comment out this line, everything else compiled without error... are we using a different compiler? LOL

Ok, I get the problem fixed, but now I am getting a new compile problem on the line

abc.Add(x);

Invalid array access, member function not defined.

But the docs says I can

https://www.mql5.com/en/docs/standardlibrary/datastructures/carraylong/carraylongadd

Documentation on MQL5: Standard Library / Data Collections / CArrayLong / Add
Documentation on MQL5: Standard Library / Data Collections / CArrayLong / Add
  • www.mql5.com
Standard Library / Data Collections / CArrayLong / Add - Reference on algorithmic/automated trading language for MetaTrader 5
 
samjesse:

Ok, I get the problem fixed, but now I am getting a new compile problem on the line

Invalid array access, member function not defined.

But the docs says I can

https://www.mql5.com/en/docs/standardlibrary/datastructures/carraylong/carraylongadd

The docs refer to object-oriented array objects that inherits from CArray class. These arrays are not the same as your abcArr[].

Reason: