// bad swap functions using overloading: // // 1. fix using reference parameters // // 2. enhance using template, test with string args // #include using namespace std; // overloading: // void swap( int a, int b) { int c = a; a = b; b = c; } void swap( double a, double b) { double c = a; a = b; b = c; } int main() { int i = 1, j = 2; cout << i << " " << j << endl; swap( i, j); cout << i << " " << j << endl; double x = 3.3, y = 4.4; cout << x << " " << y << endl; swap( x, y); cout << x << " " << y << endl; }