One of the most difficult topics about C++ functions is about passing parameters to and from a function For example it is very important to see the difference between the way parameters are passed BY VALUE (input paramters are normally passed this way - by value) and how they are passed BY REFERENCE (output parameters or those which are both input and output, i.e. those modified by the function). Here is a classical example of the situation where one needs to use the REFERENCE passing method. // This program shows how reference parameters can be used // in order to swap two values in the main program by // using a special function, swap #include using namespace std; // function prototypes void sillySwap(int, int); void smartSwap(int&, int&); int main() { int a = 1; int b = 5; // we would like to swap these values in such a way that // eventually a=5 and b=1 // Let's first output the initial values of a and b cout << "Initially: a = " << a << ", b= " << b << endl; // sillySwap is a swapping by passing actual parameters a and b // by value sillySwap(a,b); cout << "After silly swap: a = " << a << ", b = " << b << endl; // smartSwap passes references (i.e. addresses) to the values // of a and b smartSwap (a,b); cout << "After smart swap: a = " << a << ", b = " << b << endl; return 0; } // end of main() // function definitions // this function uses passing by value void sillySwap(int p, int q) { int temp = p; p = q; q = temp; return; // note that p and q have indeed swapped their // values but the values of the actuals in the main // function (a and b) have not - they are intact! } // this function uses passing by reference void smartSwap(int& p,int& q) { int temp = p; p = q; q = temp; return; // since p and q are references (aliases) to the actuals // swapping their values is the same as swapping the // values of the actuals! } ============================================= The result of the run of this program is: Initially: a = 1, b= 5 After silly swap: a = 1, b = 5 After smart swap: a = 5, b = 1 ============================================ I strongly reecommend you to go through other examples of parameter passing in the Lee and Phillips book (Sections 9.4 and 11.2) Best wishes AY