Trouble with Copy Constructor of doubly Linked List
<p>Consider the code Below:</p>

<pre><code>//In list.h

template &lt;class T&gt;
struct Node
{
    T value;
    Node&lt;T&gt; *next;
    Node&lt;T&gt; *prev;

    Node(T Val)
    {
        this-&gt;value = Val;
        this-&gt;next = NULL;
        this-&gt;prev = NULL;
    }
};
</code></pre>

<p>/* This is the generic List class */</p>

<pre><code>template &lt;class T&gt;
class List
{
    Node&lt;T&gt; *head;

public:

    // Constructor
    List();

    // Copy Constructor
    List(const List&lt;T&gt;&amp; OldList);

    // Destructor
    ~List();
}
</code></pre>

<p>// In list.cpp, I am making Copy Constructor something like this:</p>

<pre><code>template &lt;class T&gt;
List&lt;T&gt;::List(const List&lt;T&gt;&amp; OldList)
{

// first make a node to head of my old List.
        Node&lt;T&gt;* oldN = OldList.head;
// then make a new Node for the new List. and insert the same value as present
//in the old List.
        Node&lt;T&gt;* copyN = new Node&lt;T&gt;( oldN-&gt;value);
        Node&lt;T&gt;* temp;
        oldN = oldN-&gt;next;
        while (oldN!=NULL){
// I need to maintain a pointer to previous node before making a new node..
            temp = CopyN;
// Again make a new Node for the new List. and insert the same value as present
//in old List
            Node&lt;T&gt;* CopyN= new Node&lt;T&gt;( oldN-&gt;value);
            temp-&gt;next = CopyN;
            CopyN-&gt;prev = temp;
// move on to next node.
            oldN=oldN-&gt;next;
        }
// at the end, connect last node to NULL.
        CopyN-&gt;next=NULL;
    }
</code></pre>

<p>The Copy Constructor is not working. It is not making exactly a new copy of old List. I have a test.cpp and I am checking it on that. It is giving "Failed!!". Can someone see any problem with my code of Copy Constructor.</p>
