// Contrary to what might have been said at the
// end of section, this code works as written.
// Since it is a friend function, it has access to
// the private data members of the WordList class

// this code appears in main.cpp:

ostream & operator<<(ostream &cout,  WordList &wl) {
  int sum = 0;

  cout << "Frequency\tWord" << endl;

  for (int i=0; i< wl.nWords; i++) {

    sum += wl.entry[i].frequency;

    cout << wl.entry[i].frequency
         << '\t' << wl.entry[i].word
         << endl;
  }

  cout << "Total: " << sum << endl;

  return cout;
}


// and then the following would be added to
// the class WordList declaration:
friend ostream & operator<<(ostream &cout,  WordList &wl);