title: Syntax error with template in c++
body: <p>I have following code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  template&lt;class T&gt;
  T max(T *data,int len){
      int i;
      T Max=data[0];
  
       for (int i=1;i&lt;len;i++){
  
           if (data[i]&gt;max){
               Max=data[i];
  
  
       }
       }
   return  Max;
  
  }
  int mai(){
      int i[]={12,34,10,9,56,78,30};
      int len=sizeof(i)/sizeof(i[0]);
      cout&lt;&lt;max(i,len)&lt;&lt;"\n";
  
  
  
       return 0;
  }
  </code></pre>
  
  <p>But when I compile it, I get the following errors:</p>
  
  <pre><code>generic_max, Configuration: Debug Win32 ------
  1&gt;Build started 7/29/2010 1:03:25 AM.
  1&gt;InitializeBuildStatus:
  1&gt;  Touching "Debug\generic_max.unsuccessfulbuild".
  1&gt;ClCompile:
  1&gt;  generic_max.cpp
  1&gt;c:\users\david\documents\visual studio 2010\projects\generic_max\generic_max\generic_max.cpp(10): error C2563: mismatch in formal parameter list
  1&gt;          c:\users\david\documents\visual studio 2010\projects\generic_max\generic_max\generic_max.cpp(22) : see reference to function template instantiation 'T max&lt;int&gt;(T *,int)' being compiled
  1&gt;          with
  1&gt;          [
  1&gt;              T=int
  1&gt;          ]
  1&gt;c:\users\david\documents\visual studio 2010\projects\generic_max\generic_max\generic_max.cpp(10): error C2568: '&gt;' : unable to resolve function overload
  1&gt;          c:\users\david\documents\visual studio 2010\projects\generic_max\generic_max\generic_max.cpp(4): could be 'T max(T *,int)'
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\xutility(2086): or       'const _Ty &amp;std::max(const _Ty &amp;,const _Ty &amp;,_Pr)'
  1&gt;          c:\program files\microsoft visual studio 10.0\vc\include\xutility(2078): or       'const _Ty &amp;std::max(const _Ty &amp;,const _Ty &amp;)'
  1&gt;
  1&gt;Build FAILED.
  1&gt;
  1&gt;Time Elapsed 00:00:00.95
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p>Please help me to fix this problem.</p>