Create
a
message
class with a constructor that takes a single
char*
with a default value. Create a private member
char*,
and assume the constructor will be passed a static quoted character array;
simply assign the argument pointer to your internal pointer. Create two
overloaded member functions called
print( ):
one that takes no arguments and simply prints the message stored in the object,
and one that takes a
char*
argument, which it prints in addition to the internal message. Does it make
sense to use this approach rather than the one used for the constructor?
Determine
how to generate assembly output with your compiler, and run experiments to
deduce the name-mangling scheme.
Modify
Stash4.h
and
Stash4.cpp
to use default arguments in the constructor. Test the constructor by making two
different versions of a
Stash
object.
Compare
the execution speed of the
Flags
class versus the
BitVector
class. To ensure there’s no confusion about efficiency, first remove the
index,
offset,
and
mask
clarification definitions in
set( ),
clear( )
and
read( )
by combining them into a single statement that performs the appropriate action.
(Test the new code to make sure you haven’t broken anything.)
Change
Flags.cpp
so it dynamically allocates the storage for the flags. Give the constructor an
argument that is the size of the storage, and put a default of 100 on that
argument. Make sure you properly clean up the storage in the destructor.
Modify
SuperVar
so there are
#ifdefs
around all the
vartype
code as described in the section on
enum.