title: Extending std::list
body: <p>I need to use lists for my program and needed to decide if I use std::vector or std::list.
  The problem with vector is that there is no remove method and with list that there is no operator []. So I decided to write my own class extending std::list and overloading the [] operator.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>#include &lt;list&gt;
  
  template &lt;class T &gt;
  class myList : public std::list&lt;T&gt;
  {
  public:
  T operator[](int index);
  T operator[](int &amp; index);
  myList(void);
  ~myList(void);
  };
  
  #include "myList.h"
  
  template&lt;class T&gt;
  myList&lt;T&gt;::myList(void): std::list&lt;T&gt;() {}
  
  template&lt;class T&gt;
  myList&lt;T&gt;::~myList(void)
  {
  std::list&lt;T&gt;::~list();
  }
  
  template&lt;class T&gt;
  T myList&lt;T&gt;::operator[](int index) {
  int count = 0;
  std::list&lt;T&gt;::iterator itr = this-&gt;begin();
  while(count != index)itr++;
  return *itr;    
  }
  
  template&lt;class T&gt;
  T myList&lt;T&gt;::operator[](int &amp; index) {
  int count = 0;
  std::list&lt;T&gt;::iterator itr = this-&gt;begin();
  while(count != index)itr++;
  return *itr;
  }
  </code></pre>
  
  <p>I can compile it but I get a linker error if I try to use it. Any ideas?</p>