Copy constructor of linked list
<p>I am making a doubly linked list which only stores a single datatype(generic) and i need a copy constructor for it.I thought i had got it right but when i tested it using a file given by my instructor, it isn't working.When i try to debug it, the problem seems to be in constructor of linked list class in which I just set head=NULL.Is this a correct constructor</p>

<pre><code>//this is the struct i am using
struct ListItem 
{
    T value;
    ListItem&lt;T&gt; *next;
    ListItem&lt;T&gt; *prev;

    ListItem(T theVal)
    {
       this-&gt;value = theVal;
       this-&gt;next = NULL;
       this-&gt;prev = NULL;
    }
};

template &lt;class T&gt;
List&lt;T&gt;::List()
{
    head=NULL;
}


template &lt;class T&gt;
List&lt;T&gt;::List(const List&lt;T&gt;&amp; otherList)
{
     ListItem&lt;T&gt; *Headold=otherList.getHead();              
     if (Headold==NULL)
     {
        head=NULL;    //if otherlist head is NULL,new list head=0
     }
     else
     {           
         head=new ListItem&lt;T&gt;(Headold-&gt;value);    //initializing head to the string value

       //storing in temporary pointers
         ListItem&lt;T&gt; *oldnode=Headold;     
         ListItem&lt;T&gt; *newnode=head;
         while (temp-&gt;next!=NULL)
         {
            oldhead=oldhead-&gt;next;
            //making new node every instance 
            newnode-&gt;next=new ListItem&lt;T&gt;(oldhead-&gt;next-&gt;value); 
            ListItem&lt;T&gt; *newnodenext=newnode-&gt;next;
            newnodenext-&gt;prev=newnode;   //setting the previous pointer of the new node
         }
     }
}
</code></pre>
