title: Vector and []-operator overloading
body: <p>I have inherited my class from std::vector. Now I want to overload the []-operator.<br>
  When I try to assign a new value to my vector, e.g. <code>v[0]=5,</code> I should receive the message <code>OK</code>.  </p>
  
  <p>This is my code (I know, that makes no sense, I'm just playing around):</p>
  
  <pre><code>#include&lt;vector&gt;
  #include&lt;iostream&gt;
  class Vec : public std::vector&lt;int&gt; {
  public:
      int operator[](int);
  };
  
  int Vec::operator[](int i) {
      (*this)[i] = i;
      std::cout &lt;&lt; "OK";
      return 123;
  }
  
  int main() {
      Vec v;
      v[0]=5;
  }
  </code></pre>
  
  <p>Unfortunately I get the following error:</p>
  
  <pre><code>In member function ‘int Vec::operator[](int)’:
  error: lvalue required as left operand of assignmen
  In function ‘int main()’:
  error: lvalue required as left operand of assignment
  </code></pre>