title: Error: 'object' was not declared in this scope (C++)
body: <p>I'm trying to write a linked list of <code>Node</code> objects, where each <code>Node</code> contains: a string - <code>data</code>, and a pointer - <code>next</code>. To manage the list (e.g: add/remove nodes), I have <code>Node</code> objects: <code>head</code>, <code>curr</code> and <code>temp</code>. I'm trying to work out how to link up each node to the previous one when new data is added to the list, but I am having trouble doing so. The error is occuring in Node.cpp when I am trying to link the new node <code>n</code> to the <code>curr</code> nodes <code>next</code> pointer.  </p>
  
  <p><strong>LinkedList.cpp:</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include "LinkedList.h"
  #include "Node.h"
  
  using namespace std;
  
  LinkedList::LinkedList(value_type setData) {
      head.setData(setData);
      cout &lt;&lt; head.getData() &lt;&lt; endl;
  }
  
  void LinkedList::addNode(value_type addData) {
      Node n;
      n.setData(addData);
  
      if (head.getData() != "") {
          curr = head;
          while(curr.getNext() != NULL) {
              //Still writing this..
          }
          curr.setNext(n); //Is this correct?
      }
      else {
          head = n;
      }
  }
  </code></pre>
  
  <p><strong>LinkedList.h:</strong></p>
  
  <pre><code>#ifndef LINKEDLIST_H
  #define LINKEDLIST_H
  #include "Node.h"
  
  class LinkedList {
      public:
          typedef std::string value_type;
  
          LinkedList();
          LinkedList(value_type setData);
          void addNode(value_type addData);
  
      private:
          Node head;
          Node curr;
          Node temp;
  
  };
  
  #endif
  </code></pre>
  
  <p><strong>Node.cpp:</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include "Node.h"
  
  using namespace std;
  
  Node::Node() {
      data = "";
      next = NULL;
  }
  
  void Node::setData(value_type setData) {
      data = setData;
  }
  
  string Node::getData() { 
      return data;
  }
  
  void setNext(Node n) {
      next = n; //'next' was not declared in this scope error.
                //Does this assignment statement even work in this scenario?
  }
  
  Node * Node::getNext() {
      return next;
  }
  </code></pre>
  
  <p><strong>Node.h:</strong></p>
  
  <pre><code>#ifndef NODE_H
  #define NODE_H
  
  class Node {
      private:    
          typedef std::string value_type;
  
          value_type data;
          Node* next;
  
      public:
          Node();
          void setData(value_type setData);
          value_type getData();
          void setNext(Node n);
          Node * getNext();
  };
  
  #endif
  </code></pre>
  
  <p>Any help would be greatly appreciated, thanks guys.</p>