Using map with list

So I am having some major issues with my object-oriented homework problem.

The problem reads:

"Write a C++ program to read the name of a text file from input and for each word in the file
output the positions where that word occurs; further, the words should appear in alphabetical order.
For example, if the file’s content is
one
two one two
three three two one
then an acceptable output is
one: 0, 2, 7
three: 4, 5
two: 1, 3, 6
You should use a map<string, list<int> > for this problem."

if someone could at the very least tell me how to use the list container within the map container that would be awesome....
how to use the list container within the map
for "one" that would be:
1
2
3
4
map<string, list<int> > wm;
wm["one"].push_back(0);
wm["one"].push_back(2);
wm["one"].push_back(7);


See:
http://www.cplusplus.com/reference/map/map/
http://www.cplusplus.com/reference/list/list/
Topic archived. No new replies allowed.