The following is a C++ definition of the box_car
class;
evidently, the chunks of memory that describe box cars hold
values for three floating-point numbersnamely, height, width,
and length:
class box_car { public: double height, width, length; };
Here is what each part of the definition does:
class <-- Tells C++ that a class is to be defined box_car <-- Tells C++ the name of the class { <-- Marks the beginning of the body public: <-- Specifies where variables can be referenced double ...; <-- Introduces variables } <-- Marks the end of the body ; <-- Marks the end of the class definition
This definition of the box_car
class describes
height
, width
, and length
variables only; no
function definitions appear. Furthermore, this definition of the
box_car
class indicates, via the public:
symbol,
that all the variable values describing a box_car
object
will be available, and changeable, anywhere after the class
named box_car
has been defined.