String class from Project 2. Make corrections and
improvements as needed. Test your class thoroughly before proceeding.
(You do not have to turn in your test program.)
bool type, change your
String class
so that boolean functions have return type bool
rather than int. Use the
bool type for any other boolean functions in this project.
String.H, add it now.
Keep all documentation updated as
you continue to add new functions and new classes in this project.
private section to protected.
Add the const qualifier to
member functions that don't change the state of the host object. (Note
that const must be added to both the function declaration and definition.)
Your declaration of the String class should resemble the one shown below:
String class again before proceeding.
Display() function so that it takes an
ostream reference
as a parameter, with a default value of cout. The declaration
for the Display() function should now look like:
String class.
String.C. Implement the functions
as follows:
Display().
(Neither function should print a newline. This gives us greater flexibility
when using the insertion operator.)
_cptr, making sure
that _cptr points to a suitable block of memory. (Note that the
work to be done here is similar to goes on in the overloaded
assignment operator.)
IString. Put the class body in
IString.H and
function definitions in IString.C. The IString
class will be derived from
String. Objects of the IString class are just
like String objects, with
one added piece of data: an integer value that is associated with the
character string. There are number of possible uses for this type of
object:
The declaration of the IString class is shown below. Add the necessary
documentation and define all of the member functions.
IString class will inherit all of the relational operator functions as
they exist in its base class. This means that the comparison of two
IString objects is based only on examining the character strings, and that
the integer values are not considered in the comparison.
For now, the IString class does not need overloadings for the insertion and
extraction operators.
IString class thoroughly. For debugging and learning purposes,
you may want to put some temporary print statements in the various
functions (especially constructors, destructor, and operator =) in
both base and derived class. This will show you exactly when these
functions are getting called. Remove (or comment out) these statements
before submitting your project.
main() function in a file called
Proj4.C.
Your main() should contain a loop that satisifies the following
requirements:
IString object will
represent a string of binary digits paired with the corresponding
decimal value.
IString object is dynamically allocated.
IString object is displayed on the screen using the
Display() function of the Istring class.
IString object is destroyed.
Output:
The name of your executable must be Proj4.
main() which gets two integer
values from the command line and uses these to determine the range
of digit strings to generate. Put this main() in a
source file called Proj4-ex.C. Set up your makefile
so that with the single command make, it generates
both the Proj4 executable and another executable called
Proj4-ex. The output shown above would be generated
by the command line: Proj4-ex 0 15 . Other command
lines should generate approriate output.
Proj4-ex program should include error-checking
for: