This lab is worth 10 points and accounts for 12.5 percent of your laboratory grade. The points will be subjectively assigned by your TA based upon whether they believe you made a good faith effort toward complete the tasks that are assigned. Showing up on time, respecting your fellow classmates learning environment, and adherance to laboratory policies also factor into the determination of your score.
The following is an outline of the tasks for you to attempt during the lab period.
A framework containing the files and folders you will need can be found here. Download the .tgz file and decompress it in your account using the command:
tar -xzvf <file_name>
In the folder swap, write a C++ program to swap the value of two objects using pointers. To test it, use a class that has two variable members: 1) the dynamic length of a string, int length, and 2) a pointer to the characters of a string object, char *chars;.
In the folder text, you will find the complete implementation of the class StringVar. You must define a class called Text whose objects store lists of words. The class Text will be just like the class StringVar, except that it will use a dynamic array with the base type StringVar, rather than base type char; also, it will mark the end of the array with a blank StringVar object, rather than the char '\0'.
Your class Text will have member functions corresponding to all the member functions of StringVar. One constructor with an argument const char[] (i.e. a c-string) will initialize the Text object by creating a separate element of the StringVar array corresponding to each "word" in the string argument, where "words" are separated by spaces. The member function input_line will do the same as the above constructor: It will read space-separated strings and store each string in one element of the StringVar array.
In both cases (constructor and member function), multiple spaces are to be treated as single spaces, i.e. simply as word separators. The member function output should output the individual words with a single space between them. After 5 words, output a newline instead of a space.