Home Segments Index Top Previous Next

123: Mainline

It is important to know that the parameter values established when a function is entered are available only inside the function. It is as though C++ builds a isolating fence to protect any other uses of the same parameter name outside of the function. Consider box_car_volume, for example:

double box_car_volume (double h, double w, double l) { 
  return h * w * l; 
} 

When box_car_volume is used, any existing values for other variables that happen to be named h, w, and l are protected:

box_car_volume fence--------------*   The values of h, w, and l  
| The value of h, w, and l inside |   outside the fence, if any, 
| this fence are isolated from    |   are not affected by the 
| values outside                  |   values inside 
|                                 | 
| Function computes the value of  | 
| h * w * l using the values of   | 
| h, w, and l inside this fence   | 
*---------------------------------*