title: I used template to add two number for any kind of data types, but it did not work out
body: <p>What changes should be made to take any kind of data types?</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  template &lt;class T&gt;
  T add(T n1, T n2)
  {
      T res;
      res = (n1 + n2);
      return res;
  }
  int main()
  {
      double x, y;
      cout &lt;&lt; "Enter first number : "; cin &gt;&gt; x;
      cout &lt;&lt; "Enter second number : "; cin &gt;&gt; y;
      cout &lt;&lt; add(x, y);
  }
  </code></pre>