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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education