152 Introduction to C++ Programming and Graphics
Problem
6.1.1.If thestringdata type were not available, what would be a sensible
statement declaring and initializing a string variable?
6.2 Class interfaces
The member functions of a class accomplish a broad range of tasks. First, they
construct (initialize) native objects, that is, they evaluate the data fields that
uniquely define an object. Second, they allow us to view and visualize an object.
Third, they allow us to intrusively operate on an isolated object or groups of
objects.
The set of member functions pertinent to a particular class is theclass
interface.
Constructors
These member functions initialize an object. Constructors come in two
flavors:default constructorsandparametered constructors.
Suppose that we want to create the beautiful Greek sculpture of the think-
ing man. To begin, we introduce the class of all sculptures, and use the default
constructor to materialize the default sculpture, which can be a square block
of clay. Alternatively, we may use the non-default constructor to materialize a
rectangular block of clay.
Accessor member functions
These member functions non-intrusively query an object, that is, they do
so without altering its properties.
Concerning the class of sculptures, an accessor member function may
report the length of the fingernails without actually clipping them.
Mutator member functions
These member functions are able to alter the members on which they
operate.
Concerning the class of sculptures, a mutator function can act like a
chisel.