using list class.. stuck...

Okay.. so I have a

list <wordListType> dic[50];

and class wordListType is defined as follows:

class wordListType
{
list <string> words;
int wordSize;
vector <int> * wordV;
};

okay.. so my question is, how would I access wordSize? I have been trying for the last hour. I have attempted everything... like

dic[i].wordSize = wordLength;

dic[i]->wordSize = wordLength;

What am I doing wrong?
Last edited on
If you've ever tried to implement a linked list or thought about what a linked list is, you'd realise that you don't have direct access to elements, you only have direct access to the next element (and previous for a double threaded linked list).

You access elements with iterators. e.g.
1
2
3
4
5
6
7
8
typedef std::list<wordListType> container;
for (container::iterator p = dic.begin(); p != dic.end(); ++p)
{
    wordListType* entry = *p

    // use the entry--print wordSize;
    std::cout << entry.wordSize << std::endl;
}
Topic archived. No new replies allowed.