title: overload operator [] linked list
body: <pre><code>template&lt;typename T&gt;
  int&amp; listvector&lt;T&gt;::operator[](int n)
  {   
      Node*p = new Node;
      p-&gt;data = NULL;
      for(int i=0;i&lt;n;i++){
          p = p-&gt;next;
      }
      p-&gt;next = head;
      head = p;
  
      return head-&gt;data;
  }
  </code></pre>
  
  <p>I am trying to overload a operator[] in my class listvector. This operator[] is used to  add the node which is NULL to the list(n is the place that return the value of the list). For example, when in main listV[4] = new int(10), means that NULL NULL NULL NULL 10 in the list. In my code, I don't know why I can not assign NULL to 0-3   only the first one is NULL.</p>