Question: The string class is provided in the C++ library. Provide your OWN implementation for the following functions in a new string class with additional features.
The string class is provided in the C++ library. Provide your OWN implementation for the following functions in a new string class with additional features. Name your class MyString. You do not need to provide any other functions other than those listed below. The below prototypes should appear on your header file (MyString.h) and you should implement the functions in MyString.cpp.
MyString(char chars[], int size); //constructor
void append(int n, char ch) ; //appends n copies of character ch at the end of the MyString object
void assign(MyString s, int n); //assigns the first n number of characters of s into this MyString object, starting from the first character in this object
int partCompare(MyString s, int n); //returns a value greater than 0, 0, or less than 0 if this MyString objectis greater than, equal to, or less than the first n characters of s, respectively
MyString commonPrefix(const MyString &s); //returns the common prefix (*) of this MyString object ands, if any. Returns an empty MyString otherwise.
(*) Newton and Newark have the common prefix New, ABC and abc do not have a common prefix (case
sensitive), coding and cod have the common prefix cod.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
