title: c++ linked list inside another one
body: <p>I'm trying to make a linked list inside another one, here is my code</p>
  
  <pre><code>template&lt;typename T&gt;
  class List {
  private:
      int length;
      class Node {
      public:
          T data;
          Node* next;
      } *head;
  
  public:
      List();
      ~List();
  
      void insert(T item);
      void remove(T item);
      void empty();
      T* getAll();
      int count() const;       
  };
  
  template&lt;typename T&gt;
  void List&lt;T&gt;::insert(T item)
  {
      if (head == NULL)
      {
          head = new Node();
          head-&gt;data = item;
          head-&gt;next = NULL;
          length = 1;
          return;
      }
      Node* p = new Node();
      p-&gt;data = item;
      p-&gt;next = head;
      head = p;
      ++length;
  }
  
  struct Remainder {
      Date dt;
      List&lt;int&gt; notes;
  };
  
  
  void getDayEvents(Date dt, List&lt;Remainder&gt; l)
  {
      Remainder* arr = new Remainder[l.count()];
      arr = l.getAll();
      for (int i = 0; i &lt; l.count(); i++)
      {
          if (arr[i].dt.day == dt.day &amp;&amp; arr[i].dt.month == dt.month &amp;&amp;              arr[i].dt.year == dt.year)
          {
              int* nArr = new int[arr[i].notes.count()];
              nArr = arr[i].notes.getAll();
              for (int j = 0; j &lt; arr[i].notes.count(); j++)
              {
                  cout &lt;&lt; nArr[j] &lt;&lt; endl;
              }
          }
      }
  }
  
  int _tmain() {
      Date dt1, dt2;
      dt1.setDate(17, 7, 2015);
      dt2.setDate(5, 11, 2015);
  
      Remainder r1, r2;
      r1.dt = dt1;
      r1.notes.insert(1);
      r1.notes.insert(2);
      r2.dt = dt2;
      r2.notes.insert(5);
  
      List&lt;Remainder&gt; l;
      l.insert(r1);
      l.insert(r2);
  
      getDayEvents(dt1, l);
  
      //----------------------------------------------------------
      int pause;
      cin &gt;&gt; pause;
      return 0;
  }
  </code></pre>
  
  <p>just when insert r1 or r2 in the list, the data inside lists of notes inside each remainder just disappeared or destroyed</p>
  
  <p>I don't know why? Where is the mistake?</p>