This is a program to swap two numbers...implemented using template...
i am not able to understand the line......Code:#include <iostream> using namespace std; template <class T> void swap(T &x, T &y) { T temp = x; x = y; y = temp; } void fun(int m,int n,float a,float b) { cout << "m and n before swap" << m << " " << n << " " << endl; swap(m,n); cout << "m and n after swap" << m << " " << n << " " << endl; cout << "a and b before swap" << a << " " << b << " " << endl; swap(a,b); cout << "a and b ater swap" << a << " " << b << " " << endl; } int main() { fun(100,200,11.22,33.44); return 0; }
Can somebody please explain what this statement is doing...??Code:void swap(T &x,T &y)
Thanks in advance..



LinkBack URL
About LinkBacks



