I'm trying to code a template that will sort elements (whether int or double, etc). The sort somewhere calls a swap function to change the order so the elements appear in ascending order. In my main(), I would do bubbleSort(a, n) where 'a' is a pointer pointing to an array of integers (or doubles, etc) and 'n' is the size of the array. But when I compile, I get an error such as : call of overloaded 'swap(int&, int&)' is ambiguous....candidates are: void swap(T&, T&) [with T = int]
I then found out my swap function had to be coded as swap(T *a, T *b) and then everything worked fine. Why did I have to do this?