Walkthrough programming C++
For the WALKTHROUGH portion of today's Term Test, you will need to determine the EXACT output as well as keep track of changes in values of ALL class data members in a working C++ program. The exact format for how to track changes is specified BELOW. REQUIRED FILENAME: The CORRECT file name for submitting the WALKTHROUGH portion of today's Term Test (assuming a my.Seneca user id of: "tswift2" and a section of: "A") is: tswift2_PRG355A.211. TT1W.txt NOTE: The filename extension to be used MUST be .txt SPECIFICATIONS: Determine the EXACT output of the following C++ program. In the TRACKING section below, you MUST keep track of the values of ALL the data members for each class instance in main() ONLY. When ANY data member variable's value changes, you are to separate it's previous value with the 'n' character BEFORE appending the variable's NEW value. For example, to keep track of member variable 'a' in the Ocean object named 'one' in main(), you would write (assuming the integer values change from uninitialized to -1 to 0 to 1): int a=-1nw1 For example, to keep track of member variable 's' in the Ocean object named 'one' in main(), you would write (assuming the string values change from uninitialized to "C" to "CA" to "CAT"): char s[41] =C-CACAT So that, the TRACKING section for Ocean object named "one" would be: Ocean one: char s1411=CCACAT So that, the TRACKING section for Ocean object named "one" would be: Ocean one: char [41] -C-CANCAT int sk= int In int a-1 int b= To submit, paste the output from BOTH the TRACKING and OUTPUT areas (without the comments) into this web form. #include
using namespace std; #include class Ocean { char s[41]; int sk; int in; int a; int b; void set(const char *str, int n); public: Ocean(const char *str); Ocean(const char *str, int n); void show(); void operator+=(Ocean x); void Ocean::set(const char *str, int n) { strcpy(s, str); ln strlen(s); sk = n; a = b = 4; 3 Ocean::Ocean(const char *str) { set(str, 2); a++; } Ocean::Ocean(const char *str, int n) { set(str, n); bH; } void Ocean::show() { for(int i = 0; i ln >= 7) { this->b++; cout b a++; cout a s[i + this->n] X.s[i]; } this->ln += x.ln; if(this->sk sk = x.sk; int main() Ocean one ("SVEYEA"); one.show(); Ocean two("TI 021 DPW4 A5", 3), three("WHEELS", 5), four("YMCE"); two.show(); cout using namespace std; #include class Ocean { char s[41]; int sk; int in; int a; int b; void set(const char *str, int n); public: Ocean(const char *str); Ocean(const char *str, int n); void show(); void operator+=(Ocean x); void Ocean::set(const char *str, int n) { strcpy(s, str); ln strlen(s); sk = n; a = b = 4; 3 Ocean::Ocean(const char *str) { set(str, 2); a++; } Ocean::Ocean(const char *str, int n) { set(str, n); bH; } void Ocean::show() { for(int i = 0; i ln >= 7) { this->b++; cout b a++; cout a s[i + this->n] X.s[i]; } this->ln += x.ln; if(this->sk sk = x.sk; int main() Ocean one ("SVEYEA"); one.show(); Ocean two("TI 021 DPW4 A5", 3), three("WHEELS", 5), four("YMCE"); two.show(); cout