Download MetaTrader 5
To add comments, please log in or register
Do you want to write a trading robot? Find solution in MQL5 Reference!
arlevins
33
arlevins 2014.06.29 16:58 

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
2409
Drazen Penic 2014.06.29 17:10  

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 2014.06.29 17:33  
Yes, now it's OK!
/
To add comments, please log in or register