title: Having trouble with my code overwriting itself and I am not sure why
body: <p>In the code below I can change the count amount newNodePtr->setCount(amount); to any value and it will stay changed. But I am trying to set it equal to one initially. And then if it occurs again I will go to the else statement and keep my linked list value at that location but change the count by +1. </p>
  
  <pre><code>template&lt;class ItemType&gt;
  bool LinkedBag&lt;ItemType&gt;::add(const ItemType&amp; newEntry)
  {
  
      Node&lt;ItemType&gt; *newNodePtr = new Node&lt;ItemType&gt;();
      int amount = 0;
          if (getFrequencyOf(newEntry)&lt;1)
          {
              newNodePtr-&gt;setItem(newEntry);
              newNodePtr-&gt;setNext(headPtr);
              itemCount++;
              amount++;
              newNodePtr-&gt;setCount(amount);
              headPtr = newNodePtr;
  
          }
          else
          {
              const int freqAmount = getFrequencyOf(newEntry);
              newNodePtr-&gt;setItem(newEntry);
              itemCount++;
              newNodePtr-&gt;setCount(freqAmount+1);
          }
  
      return true;
  }  // end add
  </code></pre>