Contact: aviboots(AT)netvision.net.il
41,397 questions
53,943 answers
573 users
#include <iostream> template<class T> void swap(T &a, T &b) { T temp = a; a = b; b = temp; } int main() { int x = 10; int y = 25; swap(x, y); // swap<int>(x, y); std::cout << x << " " << y; } /* run: 25 10 */
#include <iostream> template<class T> void swap(T &a, T &b) { T temp = a; a = b; b = temp; } int main() { float x = 3.14; float y = 1.07; swap(x, y); // swap<float>(x, y); std::cout << x << " " << y; } /* run: 1.07 3.14 */