How to loop through each struct member of struct array?

 

Hi, I'm learning OOP on MQL4 and I am stuck on the following code. Can anyone please assist? I am new to MQL4 and this is my first post here kindly correct me if I may have broken any of the rules. I already searched quite a bit on this forum and also on stack overflow but I could not find an answer.

#property strict

enum EEnum {
   ENUM_1,
   ENUM_2,
};

struct SStruct  {
   int      mInt;
   string   mString;
   double   mDouble;
   EEnum    mEnum;

   SStruct(){
      mInt     = NULL;
      mString  = NULL;
      mDouble  = NULL;
      mEnum    = ENUM_1;
   }

   ~SStruct(){}
};


SStruct list[];

// Code to print each struct member names and value
template <typename T>
void pValue (int index, ??? smember, T smvalue){
   PrintFormat("list[%i].%s value = %T", index, smember, smvalue);
}

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart(){

   int size = ArraySize(list);
   
   if (size <= 0){
      ArrayResize(list, size+1);
   };
   size = ArraySize(list);
   
   // loop through array
   for (int i=0; i<size; i++){
      // code to iterate struct members
      for (each structmember){
         pValue(i, structmember, membervalue);
      };
      
   };
}
//+------------------------------------------------------------------+
 
aik3e: Hi, I'm learning OOP on MQL4 and I am stuck on the following code. Can anyone please assist? I am new to MQL4 and this is my first post here kindly correct me if I may have broken any of the rules. I already searched quite a bit on this forum and also on stack overflow but I could not find an answer.

You can't loop through members of a "struct" nor a "class". They are not part of some kind virtual array of members nor a list of virtual pointers. They are only directly addressable as member variables (or member functions if it be the case).

 
Fernando Carreiro:

You can't loop through members of a "struct" nor a "class". They are not part of some kind virtual array of members nor a list of virtual pointers. They are only directly addressable as member variables (or member functions if it be the case).

Thank you @Fernando. I was suspecting that that was the case but was hopeful there was a workaround.