Question: 9. Consider the class newString as described in the newString Programming Example: class newString { public: . . . private: char *strPtr; // pointer to
9. Consider the class newString as described in the newString Programming Example:
class newString
{
public:
.
.
.
private:
char *strPtr; // pointer to the char array that holds the string
int strLength; // variable to store the length of the string
};
a. Overload the operator + to perform string concatenation. For example, if s1 is "Hello " and s2 is "there", the statement: s3 = s1 + s2; should assign "Hello there" to s3, where s1, s2, and s3 are newStringobjects.
b. Overload the += operator to perform the string concatenation as follows. Suppose that s1 is "Hello " and s2 is "there". Then the statement: s1 += s2;should assign "Hello there" to s1, wh+6++ere s1 and s2 are newStringobjects.
You may use the functions strcat() and strlen() from the cstring library.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
