Refer to the word count program discussed in class. A modified version of this program has been placed in the directory ~jnw/OOCourse. Minor (but important) changes such as addition of copy constructors and assignment were made to the version given in class. You are to make the rest of the modifications specified below.
Modify the program so that WordCountTable is an abstract
base class that has a public print member function
(printing the contents of the table).
Modify the WordCountTable class constructors as follows
EntryArray member
of the WordCountTable class.
operator<< on WordCountTable objects
to employ the print member function and not to be a
friend of WordCountTable.
Add the following two derived classes of WordCountTable:
GenericWordCountTable, implementing a table just
like the one that the program now implements
SortedWordCountTable, implementing a table that
will yield a lexicographically sorted list of the words
in the table when it is printed.
SortedWordCountTable class. One may have an insertion
method that maintains a sorted array of the words in the table
or one may sort the elements when asking for them to
be printed. A variety of variations on these themes are possible.
No matter what mechanism is chosen, some of the member functions of the
WordCountTable class will need to be virtual. Others may
not need to be virtual. Try to avoid derived class duplication of
structure or behavior provided by the base class.
Change the main program so that it accepts a single command line argument,
a single character, which is either g or s
to indicate that the WordCountTable to be employed is either
a generic or a sorted table, respectively.
Have it assign a WordCountTable pointer variable a new
reference to either a GenericWordCountTable or
SortedWordCountTable depending on the value of the command
line argument.
The rest of the main program should behave as in the provided version.
It will, of course, employ a WordCountTable pointer variable
rather than a WordCountTable variable.
Make sure not to include extraneous code or bogus debugging output in your program. This is unprofessional. Provide internal documentation sufficient to allow you to pick up the code in 6 months and figure out what you did.