/* Author: Yan Huang (01.18.07) to show how to use template */ #include #include template void swap(T &a, T &b) { T c = a; a = b; b = c; } void main(){ int a = 5, b = 6; string c = "Huang", d = "Yan"; swap(a,b); cout << " a = 5 and b = 6 " << "after swap " << "a = " << a << " and b = " << b << endl; swap(c,d); cout << " c = Huang and d = Yan " << "after swap " << "c = " << c << " and d = " << d << endl; }