Member functions can have ordinary arguments in addition to the
special class-object argument. You might, for example, have a
member function named scaled_volume
that multiplies the
volume of its class-object argument by a scale factor supplied
as an ordinary argument:
*-- Class-object argument | | *-- Ordinary argument | | v v x.scaled_volume (0.95)
The definition of a scaled_volume
member function is
similar to that of a volume
member function. The only
difference is the addition of an ordinary parameter,
scale_factor
:
class box_car { public: double height, width, length; double scaled_volume (double scale_factor) { return scale_factor * height * width * length; } };