You are given two files mystring1.h download and mystring1.cpp download which defines a String class (noted that upper case S, C++ is case sensitive) implemented by using static array as the data member. The purpose of this is to rewrite this class by replacing the static array with a pointer (dynamic array). You are required to modify the String class accordingly: Data: we wish to allow our String class to accommodate strings of different sizes. To that end, instead of storing a string’s characters in a fixed-size array, each String object should contain the following data as part of its internal representation: (1) a character pointer meant to point to a dynamically allocated array of characters. (2) a length field that will hold the current length of the string at any given moment. Operations: same as the methods in String class, plus the “big three”( destructor, copy constructor, and assignment operator overloading). Modularity: The String class code must be put in its own module, i.e., a file mystring2.h (the header file) should hold the class definition (use conditional compilation directives) and a file mystring2.cpp (the implementation file) should hold the program code for all the functions defined in the header file. Upload two files: mystring2.cpp and mystring2.h. I have attached mystring1.h and mystring1.cpp to the picture.
You are given two files mystring1.h download and mystring1.cpp download which defines a String class (noted that upper case S, C++ is case sensitive) implemented by using static array as the data member. The purpose of this is to rewrite this class by replacing the static array with a pointer (dynamic array). You are required to modify the String class accordingly:
Data: we wish to allow our String class to accommodate strings of different sizes. To that end, instead of storing a string’s characters in a fixed-size array, each String object should contain the following data as part of its internal representation:
(1) a character pointer meant to point to a dynamically allocated array of characters.
(2) a length field that will hold the current length of the string at any given moment.
Operations: same as the methods in String class, plus the “big three”( destructor, copy constructor, and assignment operator overloading).
Modularity: The String class code must be put in its own module, i.e., a file mystring2.h (the header file) should hold the class definition (use conditional compilation directives) and a file mystring2.cpp (the implementation file) should hold the program code for all the functions defined in the header file. Upload two files: mystring2.cpp and mystring2.h.
I have attached mystring1.h and mystring1.cpp to the picture.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images