Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q1. Strings and Class Design. [35 points] The string class is provided in the C++ library. Provide your OWN implementation for the following functions in
Q1. Strings and Class Design. [35 points] 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 object is 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 and s, 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". Make sure to test your MyString class thoroughly, but do not include your test code in your submission
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started