title: Explicit template argument specification
body: <p>I started reading about templates and I got confused on the below.</p>
  
  <pre><code>template&lt;class T&gt;
  T max(T t1, T t2)
  {
     if (t1 &gt; t2)
        return t1;
     return t2;
  }
  
  int main(){
     std::cout&lt;&lt;max&lt;int&gt;(120,14.55);
     return 0;
  }
  </code></pre>
  
  <p>Output is 120. But when I compiled the above I got this warning:</p>
  
  <pre><code>warning:passing double for argument 2 to T max(T, T) [with T = int].
  </code></pre>
  
  <p>My question is why this warning came, since I have already instantiated for <code>T max(int t1,double t2)</code>.</p>
  
  <p>Because as per my understanding here if I explicitly mention only one data type (here <code>int</code>), other would be deducted from the argument type (<code>14.55</code>) by the compiler. That means <code>T max(T t1, T t2)</code> instantiates <code>T max(int t1,double t2)</code> in this case. I read this concept from some template documents on Internet.</p>
  
  <p>Please clear my doubts else I can't proceed further.</p>