Array of Function Pointers compilation error in MQL5

 

The below script compiles and works fine in MQL4 but throws compilation error(some operator expected) in MQL5. I hope someone can guide me and help in rectifying the issue.


typedef string(*TFunc)(string &text);
TFunc funcPtr[4];

void OnStart()
  {
   funcPtr[0] = A;
   funcPtr[1] = B;
   funcPtr[2] = C;
   funcPtr[3] = D;
   
   for(int i=0;i<4;i++)
     {
      string text = IntegerToString(i);
      Print(funcPtr[i](text));
     }
  }
  
string A(string &text) {
 return(text);
}
string B(string &text) {
 return(text);
} 
string C(string &text) {
 return(text);
} 
string D(string &text) {
 return(text);
}   
 
Navdeep Singh:

The below script compiles and works fine in MQL4 but throws compilation error(some operator expected) in MQL5. I hope someone can guide me and help in rectifying the issue.

It's a bug in metatrader's compiler, a workaround would be to do:

      TFunc p = funcPtr[i];
      Print(p(text));
 
Alexandre Borela #:
It's a bug in metatrader's compiler, a workaround would be to do:

Thanks a lot :) 

 
Reported to Metaquotes and fixed. Will be available on next build.
 
Alain Verleyen #:
Reported to Metaquotes and fixed. Will be available on next build.
Thanks