template <class insertionCode>
void insertion(insertionCode a[], int n)
{
int i, j;
for (i = 1; i < n; ++i)
{
j=i;
while (j>0 && a[j-1]>a[j])
{
swap<insertionCode> (a[j-1], a[j]);
j--;
}
}
}
I get error when I compile it. How can I solve this problem?
It's because your swap function and the standard swap function have the same signature.
Either change the name of your function (my_swap) or put it in your own namespace (my::swap).