$25
§ String Class
You will complete the implementation for a version of the Standard Library’s string class. Please download and read through this header file: mystring.h
You are to write the implementation for the above header file in a file named mystring.cpp. Please note that the name of the actual class that you are writing is string, not mystring. For this reason, the use of namespaces is particularly important to this lab, as your class will have the same name as that of the Standard Library's string class.
You are allowed to use functions from the library <cstring> to assist you in writing your functions for things like copying between strings or appending strings to one another. You are to make sure, however, that you use safe versions of these strings. For example, you should use strncpy and strncat, not their less secure alternatives of strcpy and strcat. Finally, you may NOT use the "strdup" function.
Some of the important functions to be implemented are:
• A new constructor that has one parameter (a character). The constructor initializes the string to have just this one character.
• An insertion function that allows you to insert a string at a given position in another string.
• A deletion function that allows you to delete a portion of a string.
• A replacement function that allows you to replace a single character in a string with a new character.
• A replacement function that allows you to replace a portion of a string with another string.
• A search function that searches a string for the first occurrence of a specified character.
• A search function that counts the number of occurrences of a specified character in a
string.
• A more complex search function that searches through a string for an occurrence of some smaller string.
Please refer to the header file for the full list of functions that should be implemented. Also, more information about the implementation of the string class is available in “Slide Set 4”.
Before submitting, make sure to write a test file to thoroughly test all of the functions of your class. I recommend that, for this test file, you do not use the namespace std (i.e. don't have the line "using namespace std" in your code). It will likely be easier to just use your namespace: coen79_lab5. If you don't like putting std:: in front of cout, cin, and endl every time you write them, you can use lines like "using std::cout", "using std::cin", etc.