Given this class definition: // This class implements a simplified form of the native C++ string. (Essentially a c-String) class newString { //Overload the stream insertion and extraction operators. friend ostream& operator << (ostream&, const newString&); friend istream& operator >> (istream&, newString&); public: // assignment overload here // * (multiplication) overload here // Constructors and destructor here private: char *strPtr; //pointer to the char array that holds the string int strLength; //variable to store the length of the string }; 1)Extend the above definition to include prototypes for the default and copy constructors, and the destructor, as well as overloads for the assignment and * operators. (See step 2 for example of the * operator.) 2) Write the definitions for the functions added in step 1. Note: The * operator will create a string with x concatenated copies of the first operand as shown here: newString s1 = "Hello"; newString s2 = s1 * 3; cout << s2; Output: HelloHelloHello 3)Provide a test program demonstrating the working class. Note: You can assume all code is contained in a single file and the definitions of any other functions shown have been provide
Given this class definition:
// This class implements a simplified form of the native C++ string. (Essentially a c-String)
class newString {
//Overload the stream insertion and extraction operators.
friend ostream& operator << (ostream&, const newString&);
friend istream& operator >> (istream&, newString&);
public:
// assignment overload here
// * (multiplication) overload here
// Constructors and destructor here
private:
char *strPtr; //pointer to the char array that holds the string
int strLength; //variable to store the length of the string
};
1)Extend the above definition to include prototypes for the default and copy constructors, and the destructor, as well as overloads for the assignment and * operators. (See step 2 for example of the * operator.)
2) Write the definitions for the functions added in step 1. Note: The * operator will create a string with x concatenated copies of the first operand as shown here:
newString s1 = "Hello";
newString s2 = s1 * 3;
cout << s2;
Output: HelloHelloHello
3)Provide a test program demonstrating the working class.
Note: You can assume all code is contained in a single file and the definitions of any other functions shown have been provided.
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)