#include <vector>
#include <iostream>
#include <string>
#include <map>

using namespace std;

class document
{
public:
    void missingMap(string, int);
    void displayMap() const;            // this should be const

private:
    map<string, vector<int>> misspelled;
};



void document::missingMap(string word, int lineNum)
{
    misspelled[word].push_back(lineNum);
}

void document::displayMap() const       // this should be const
{
    typedef map<string, vector<int>>::const_iterator map_iter;
    typedef vector<int>::const_iterator vec_iter;

    for ( map_iter i = misspelled.begin(); i!= misspelled.end(); ++i )
    {
        cout << i->first << ": ";
        for (vec_iter j = i->second.begin(); j != i->second.end(); ++j)
        {
            cout << *j << ' ' /* << endl */;    // Don't end the line here.
        }

        cout << '\n';                           // end the line here.
    }
}

int main()
{
    document doc;
    doc.missingMap("debugging", 1);
    doc.missingMap("process", 2);
    doc.missingMap("removing", 2);
    doc.missingMap("programming", 3);
    doc.missingMap("process", 4);
    doc.missingMap("putting", 4);

    doc.displayMap();
}