Assignment #5, COP-3337
Implement some improvements and extensions to the
String class.
Items with * are extra credit.
This assignment is due at the start of class, Feb 20.
Start early; this assignment is substantial.
Required Improvements
You must implement the following improvements:
- Add a data member to store the current string length, thus
avoiding repeated calls to strlen for [].
(Exercise 2.33 (a)).
- Add operator+ and operator+= to perform
string concatentation with a String as parameter.
Watch out for aliasing in the += case.
(Exercise 2.33 (c)).
- Improve operator+= that is written with a
char as parameter.
If the String is full, double the capacity, so that
repeated calls to += do not require repeated array expansion.
-
Add operator* and operator*= to expand into multiple copies.
(Exercise 2.33 (d)).
-
Add the LowerCase and UpperCase member functions.
(Exercise 2.33 (f)).
-
Implement a SubString member function.
You may not use repeated calls to operator+=
to do it.
-
*
Overload operator(), with two parameters, and have
it call SubString.
-
* Define friend functions for the six relational/equality operators
that take a const char * as the first parameter and
a String as the second parameter.
Also define member functions for the six relational/equality
operators that take a const char *
as a parameter.
This is in addition to the six relational/equality member
functions that are already defined (and take a String
as a parameter).
What To Submit
You must write a program that tests your String
class extensively.
Part of your grade will be based on how exhaustive your
testing is.
Submit the test program, and your complete String
class, along with sample output.