Hello, I have some question:
Code:
template<class T> void swap(T* a, T* b) { T temp = *a; *a = *b; *b = temp; } int x,y; swap(&x,&y); swap(x,y); //why this compile and it works?
For what I knew, with void swap(T* a, T* b), should only work swap(&x, &y);Code:
template<class T> void swap(T* a, T* b) { T* temp = *a; *a = *b; *b = temp; // *b = *temp; /*with this same problem before */ } int x,y; swap(&x, &y); //why now this doens't compile? swap(x, y); // why this compile
Thanks in advance.

