Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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. #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started