C++ : Can't pass generic function to another one as a parameter <p>I want to pass multiple compare functions to the selection sort function as shown below but i get the fallowing error : </p> <pre><code>Error 1 error C2664: 'sort' : cannot convert parameter 3 from 'bool (__cdecl *)(int,int)' to 'bool *(__cdecl *)(T,T)' c:\users\milad\documents\visual studio 2008\projects\functionpass\functionpass\passcompare.cpp 49 FunctionPass </code></pre> <p>Code :</p> <pre><code>bool integerCompare (int a , int b) { return(a&lt;b); } bool charCompare (char a , char b) { return(a&lt;b); } bool stringCompare (string a , string b) { if(a.compare(b)&lt;0) return true; else return false; } template &lt;class T&gt; void sort(T x[], int n , bool(*whichCompare(T,T))) // n=size of the array { for (int pass=0; pass&lt;n-1; pass++) { int potentialSmallest = pass; for (int i=pass+1; i&lt;n; i++) { if ((*whichCompare)(x[i],x[potentialSmallest])) { potentialSmallest = i; } } int temp = x[pass]; x[pass] = x[potentialSmallest]; x[potentialSmallest] = temp; } } template &lt;typename T&gt; void printArray(T a[], int size) { for(int i=0;i&lt;size;i++) cout&lt;&lt;" "&lt;&lt;a[i]; } int main() { int intArray[] = {1,7,-8,-14,46,33,4}; sort &lt;int&gt;(intArray , 7 , integerCompare); printArray&lt;int&gt;(intArray,7); } </code></pre>