How do I turn the fucntion sumVec into a template function : <p>I got this code (I know it's in Spanish I can translate if needed) where they give me the function SumVec. What the function does is it receives as parameters two arrays (integer pointers) and an integer (size) and returns a pointer to the sum of the two vectors or arrays. I have to convert it so it can receive any type, not just integer. I know that you do that with a template by using "template " but I've only done simple classes I don't know how to do it with pointers. Any help?</p>

<p>The code</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
using namespace std;
int * sumVec(int*, int*, int);
int main() {
int n, nCol, nFil = 0;
//Arreglo unidimensional din�mico
int *ptr, *suma, size;
cout &lt;&lt; "Cuantos Items va a procesar:";
cin &gt;&gt; size;
ptr = new int[size];//Asignando memoria al arreglo
//input
for (int i = 0;i&lt;size;i++) {
cout &lt;&lt; "Ingrese el numero de Items NO." &lt;&lt; i + 1 &lt;&lt; " :";
cin &gt;&gt; ptr[i];
}
//Mostrando el contenido del archivo
for (int i = 0;i&lt;size;i++) cout &lt;&lt; "\nItem. NO." &lt;&lt; i + 1 &lt;&lt; " :" &lt;&lt; ptr[i];
cout &lt;&lt; endl;

suma = sumVec(ptr, ptr, size);

//Mostrando el contenido de la suma
for (int i = 0;i&lt;size;i++) cout &lt;&lt; "\nSuma Item. NO." &lt;&lt; i + 1 &lt;&lt; " :" &lt;&lt; suma[i];
cout &lt;&lt; endl;

delete[]ptr;//Liberando la memoria asignada al arreglo unidimensional.

return 0;
}
int * sumVec(int* Array1, int* Array2, int Size){
  int *ptr = new int[Size];
  for(int i=0; i&lt;Size; i++)
    ptr[i]= Array1[i] + Array2[i];

  return ptr;
}
</code></pre>
