Help me I still did not understand about itterator "->".
Need your help. |
Look at what you're doing here:
1 2 3 4
|
list<string> mylist;
list<string>::iterator it;
//...
it->frequency ++;
|
mylist is a
list<string>
. Note that the part in the <angle brackets> is 'string'. This means that each element inside the list is a string.
When you have an iterator, it refers to a single element inside that list. In your case, this means an iterator refers to a string.
The -> operator is like saying "Okay, this iterator is referring to a string, and I want to do something with that string." In your case, you are doing this:
it->frequency ++;
So you're saying "I want to increase that string's frequency by 1".
Make sense so far?
All of that is fine and good... but your problem (and the thing that is giving you the error) is that
strings do not have a frequency, so what you're trying to do doesn't make any sense.
Your frequency variable is not inside the string, but is inside your 'infoType' struct. Therefore, your list is wrong. You want a list of infoTypes, not a list of strings:
|
list<infoType> mylist; //<- a list of infoTypes
|