Lab 5. Multiple objects and function parameters.

Again I am providing skeleton source code for a program that counts the number of characters and lines typed by the user at the keyboard. Complete the skeleton so that it reports the number of characters excluding newline characters, and the number of lines.

For example, here is sample input and output:

% a.out
This is
some input
^D
Number of lines = 2
Number of characters = 17
%

YOU MAY NOT BE ABLE TO FINISH THIS ASSIGNMENT IN THE LAB SESSION, PLEASE COMPLETE IT IN YOUR OWN TIME. THE DUE DATE IS WEDNESDAY, FEBRUARY 22ND., BY 5 PM

Follow these steps to complete the assignment:

  1. Download the source code by shift-clicking here.
  2. Use the editor to add methods to the Counter class to:
  3. Compile and run the program several times to test its results.
  4. Run the program once more with the same input given above. Redirect the output to a file and insert a copy of the output in the source code file.
  5. Print the file with the source code and results and hand it to me (RTH).
  6. Send the source code only to the grader as lab5 using the assignment submitter.

Points to note:

% a.out < input.file

exit(1);

void print(string str) {
       cout << str << ...
}

#include <string>

(Note there is no .h on it)