Question: Can anyone solve this code? that can hold a Write the code for a class called StringShifter char array of up to 80 characters. The

 Can anyone solve this code? that can hold a Write thecode for a class called StringShifter char array of up to 80

Can anyone solve this code?

that can hold a Write the code for a class called StringShifter char array of up to 80 characters. The StringShifter class is prototyped exactly as specified below: class StringShifter { char data[81]; public: StringShifter(); Stringshifter(const char *si); void alterEven(const char *sa); void show(int n); int operator++(); }; Public features of a StringShifter object are: 1. By default, a StringShifter object sets its data array to the string "empty" when created. 2. A Stringshifter object may also be created by accepting a constant null-terminated string "si" and copies the characters from "si" (using no more than 80 characters) into the data array. If "si" contains more than 80 characters, only the first 80 are copied. 3. A member function: void alterEven(const char *sa) This function copies all of the characters at EVEN index positions (0, 2, 4, 6, etc) from the constant string "sa" into the data array (starting at index 0). This function copies the character '+' into all of the ODD number index positions in the data array. This function must NEVER move beyond the end of either the "sa" or data arrays and must also always copy the null byte to the end of the data array. NOTE: Any characters previously in the data array are OVERWRITTEN. For example, given a StringShifter object named ssy, then: ssy.alterEven("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); // would set data to: A+C+E+G+I+K+M+O+Q+S+U+W+Y+ SsY.show(8); // displays: I+K+M+O+Q+S+U+W+Y+ and a newline 4. A member function: void show(int n) This function displays the characters in the data array starting at index 'n'. If 'n' contains a value that is beyond the end of the string or if 'n' is less than o, then the show() function does not display anything. For example, if the data array in a StringShifter object named ss1 contains the string: "This is a C++ class", then ss1.show(5); // would display: "is a C++ class" and a newline (no quotes "") ss1.show(29); // would display nothing 5 A member function: int operator++) This function changes every alphabetic character (except 'z' or 'z') in the data array by increasing each character's ascii value by 1. This function also returns the total number of characters that have been changed. For example, if a Stringshifter object named ss2 contains a data string of: "This is a C++ class Zzzz... the end!", then rv = ++552; 1/ changes the data string to: "Uijt jt b D++ dmbtt Zzzz... uif foe!" and returns 19 // Your solution may ONLY use functions from the following // included C and C++ library header files. #include using namespace std; #include #include class StringShifter { char data[81]; public: Stringshifter(); StringShifter (const char *si); void alterEven(const char *sa); void show(int n); int operator++(); int main() { int rv; StringShifter ss1("This is a C++ class"), ss2("This is a C++ class Zzzz... the end!"), ssY; // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 StringShifter ss3("This is a very long phrase & the entire contents of this string should stop here-all chars from the hyphen onward should be ignored"); 553.show(); // displays: This is a very long phrase *amp; the entire contents of this string should stop here ssy.show(2); // displays: pty ssy.alterEven("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); // would set data to: A+C+E+G+I+K+M+O+Q+S+U+W+Y+ SSY.show(8); // displays: I+K+M+0+Q+S+U+W+Y+ rv = ++55Y; // changes the data string to: B+D+F+H+3+L+N+P+R+T+V+X+Z+ ssY.show(); // displays: B+D+F+H+3+L+N+P+R+T+V+X+Z+ cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!