Project 4 - MyString Class
Due: Thursday, July 2 (11:59PM)
Objective
This assignment will give you practice working with dynamic memory allocation, overloading various operators, creating a copy constructor and c-strings.
Task
You will create a MyString class that stores and performs various operations with a string. The header and a skeleton implementation file have been provided for you :
mystring.h
mystring.cpp
You should not change mystring.h in any way. I will test your code with the mystring.h above.
A string is internally represented as a dynamically allocated c-string pointed to by 'str'. 'str' is NULL terminated and 'length' represents the length of the string (not including the terminating NULL char).
The skeleton implementation file contains descriptions of all of the functions you must write to complete the MyString specification. You may need some of the string manipulation functions in including strcpy, strcmp and strlen. You can find more information about these functions by typing 'man strcpy' (or similar) on a unix machine (like linprog).
Driver Program
In addition to the completed implementation file, you must also turn in a driver file which tests the complete functionality of your implementation. Your tests should be simple but should also prove the correctness of your solution. The driver file should be well commented indicating where each feature is tested and the expected output.
Approach
You should begin by commenting out all the functions in the header and implementation file. Then, for each function, uncomment the function in the header and implementation file, write the function and test it in your driver file. This way you can incrementally build the driver file you will eventually turn in.
General Requirements:
-
No global variables, other than constants
-
When you write source code, it should be readable and well-documented.
For Project 4, submit the following files via Blackboard:
mystring.cpp
driver.cpp