title: Check if data is already in list
body: <p>I am working on a linked list project and I have two functions that I can't get to work right.</p>
  
  <p>First I have a insert function that adds an element to the list. But the function first wants to check if the element is already in the list. It should do that by using the bool function contain(). That should return true if the element is already in the list</p>
  
  <p><strong>my insert function:</strong></p>
  
  <pre><code>void StringSet::insert(string element)
  {
      NodePtr temp =head;
      if (contains("element") == true)
      {
          return;
      }
      if(head == NULL)
      {
          head = new StringNode;
          head-&gt;setData(element);
          head-&gt;setLink(NULL);
      }
      else
      {
          temp = new StringNode;
          temp-&gt;setData(element);
          temp-&gt;setLink(head);
          head = temp;
      }
  
  }
  </code></pre>
  
  <p><strong>And my contain function:</strong></p>
  
  <pre><code>bool StringSet::contains(string element)
  {
        NodePtr temp = head;
  
      while(temp != NULL)
      {
          if (temp-&gt;getData() == element)
          {
              cout&lt;&lt;"This country has already been registered!"&lt;&lt;endl;
              return true;
          }
  
          temp = temp-&gt;getLink();
      }
  
  
  }
  </code></pre>