Member-function definitions differ from ordinary function definitions in the following respects:
Thus, you define volume
as a member function as follows:
class box_car { public: double height, width, length; double volume ( ) { return height * width * length; } };
When this volume
member function is called on a particular
box_car
object, the height
, width
, and
length
variables appearing in the definition of
volume
automatically refer to the height
,
width
and length
member variables associated with that
particular box_car
object.