Note that a function with a call-by-reference parameter can
alter the corresponding
argument. The following, for example, would reset a box_car
object's percentage_loaded
member variable to 100:
void loading_function (box_car& b) { b.percentage_loaded = 100; return; }
The following alternative would not work, because the change would alter only a copy of the argument, rather than the argument itself:
void loading_function (box_car b) { // DEFECTIVE! b.percentage_loaded = 100; return; }