#include #include using namespace std; // The variables in swap() are passed by reference. Changes are // actually made to the arguments. If the main function is run // with swappy() instead, the actual arguments are not changed. // Notice that the actual function call in main() looks just // like every old function call. void swap( float &x, float &y ); void swappy( float x, float y ); int main() { float p = -3.14, q = 2.72; cout << "p = " << p << " and q = " << q << endl; cout << "And now the swap..." << endl; swap( p, q ); cout << "p = " << p << " and q = " << q << endl; cout << "\n\n"; system( "PAUSE" ); return( EXIT_SUCCESS ); } void swap( float &x, float &y ) { float temp = x; x = y; y = temp; } void swappy( float x, float y ) { float temp = x; x = y; y = temp; }