Download MetaTrader 5

template functions overloading is not supported yet in MQL4

To add comments, please log in or register
arlevins
33
arlevins  

Hi,

 I'm trying to use templates in my program, however compiler produces error 'template functions overloading is not supported yet'. My code is following:

template<typename T>

void Create(T arr[])

  {


  } 

 

 I have metatrader version 4.00 build 646. As I have understood from documntation this version should support templates.

Drazen Penic
2685
Drazen Penic  

Hm, I just copied this code from the help and it compiled without problem:

template<typename T>
T ArrayMax(T &arr[])
  {
   uint size=ArraySize(arr);
   if(size==0) return(0);          
   
   T max=arr[0];
   for(uint n=1;n<size;n++)
      if(max<arr[n]) max=arr[n];
//---
   return(max);
  }

 

Mt4, build 646, MetaEditor v.934

I did not run that code though. 

 

Add "&" in front of "arr[]" in the function specification. Arrays can be passed by reference only. Maybe that is the reason for compiler error. 

arlevins
33
arlevins  
Yes, now it's OK!
To add comments, please log in or register