title: printing a (singly) linked list in c++
body: <p>OK, first I have my node structure</p>
  
  <pre><code>struct node {   
      string s;   
      node * next; 
  };
  </code></pre>
  
  <p>And It's located within a class</p>
  
  <pre><code>    class strSet{
  private:
  
      node * first;
  </code></pre>
  
  <p>And I can construct the list, and i've made checks to see it's being constructed (it is), but when i try and print it.. "Empty Set" is printed</p>
  
  <p>This is my code to "print" it: (I've tried many variations of declaring a temp pointer, and still nothing) </p>
  
  <pre><code>node *temp = new node;
      temp = first;
      if (temp == NULL) cout &lt;&lt; "Empty set" &lt;&lt; endl;
      else {
      //  node * temp = new node;
  
          while (temp != NULL){
              cout &lt;&lt; temp-&gt;s &lt;&lt; endl;
              temp = temp-&gt;next;
          }
      }
  </code></pre>
  
  <p>Any help is appreciated, Thanks</p>
  
  <p>EDIT: I have a function that makes a singleton list (this is for an assignment), the code is:</p>
  
  <pre><code>node *first = new node;
  first-&gt;s = s;
  cout &lt;&lt; first-&gt;s &lt;&lt; endl;
  first-&gt;next = NULL;
  </code></pre>
  
  <p>The third line prints out the element when I add it</p>
  
  <p>And yes i know there is a memory leak</p>