title: delete smallest node in a linked list
body: <p>I tried to write following function to delete the smallest node in a linked list. But, i am getting error and am not able to rectify it. please help.</p>
  
  <p>error is -> Error   1   error C4703: potentially uninitialized local pointer variable 'trailSmall' used</p>
  
  <p>here is my code:</p>
  
  <pre><code>void linkedListType&lt;T&gt;::deleteSmallest()
  {
  nodeType&lt;T&gt; *current;
  nodeType&lt;T&gt; *trailCurrent;     // used for pointing to node just before current
  
  nodeType&lt;T&gt; *small;
  nodeType&lt;T&gt; *trailSmall;     
  
  if (first == NULL)
      cout &lt;&lt; "Cannot delete from an empty list." &lt;&lt; endl;
  else
      if (first-&gt;link == NULL)
      {
          first = NULL;
          delete last;
          last = NULL;
      }
      else
      {
          small = first;
          trailCurrent = first;
          current = first-&gt;link;
  
          while (current != NULL)
          {
              if (small-&gt;info &gt; current-&gt;info)
              {
                  trailSmall = trailCurrent;
                  small = current;
              }
  
              trailCurrent = current;
              current = current-&gt;link;
          }
  
          if (small == first)
              first = first-&gt;link;
          else if (small != first)
          {
              trailSmall-&gt;link = small-&gt;link;
  
              if (small == last)
                  last = trailSmall;
          }
  
          delete small;
      }
  }
  </code></pre>