Note that there are some explanatory texts on larger screens.

plurals
  1. POiterate through list of linked list
    primarykey
    data
    text
    <p>I am kind of new to c++ and got headache with this pointer and stuff!</p> <p>I need to iterate through list of struct which is linked list, read the data of struct and pop that entry! </p> <p>this my struct :</p> <pre><code>struct node { map&lt;string,double&gt; candidates; double pathCost; string source; node *next; // the reference to the next node }; </code></pre> <p>by reading <a href="https://stackoverflow.com/questions/1085489/stl-list-to-hold-structure-pointers">this</a> post I create my list like :</p> <pre><code>list&lt;node*&gt; nodeKeeper; </code></pre> <p>and then initialized the first value:</p> <pre><code> node *head; head= new node; head-&gt;pathCost = 0.0; head-&gt;source="head"; head-&gt;next = NULL; </code></pre> <p>thin fill the list and struct :</p> <pre><code>for(unsigned int i = 0; i &lt; sourceSentence.size(); i++){ node *newNode= new node; //create a temporary node //DO STUFF HERE //push currunt node to stack nodeKeeper.push_back(newNode); head = newNode; } </code></pre> <p>now I have list of struct and I want to iterate through it and pop the elements:</p> <pre><code>for (list&lt;node*&gt;::const_iterator it=nodeKeeper.begin();it!=nodeKeeper.end();it++){ it-&gt;pop_front(); } </code></pre> <p>which gives me this error:</p> <blockquote> <p>error: request for member 'pop_front' in '* it.std::_List_const_iterator&lt;_Tp>::operator->()', which is of pointer type 'node* const' (maybe you meant to use '->' ?) make: *** [main3.o] Error 1</p> </blockquote> <p>It looks like that my iterator points inside the list , not the list itself! </p> <p>Can you tell me what is wrong here?!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload