title: c++ operator[] overloading
body: <p>I need to overload operator[] in c++, but with checking what r-value is.</p>
  
  <pre><code>class polynomial
  {
      int n; //polynomial degree
      double *a; //array of polynomial value
      {...}
      polynomial::polynomial (initializer_list&lt;double&gt; p)
      {
          n = p.size()-1;
          a = new double[n+1];
          copy(p.begin(), p.end(), a);
      }
      double&amp; polynomial::operator [] (const int i)
      {
          return a[n-i];
      }
  }
  
  main()
  {
      polynomial p = {1,2,3};
      p[0]=0;
  }
  </code></pre>
  
  <p>And i want throw exception if there is <code>=0</code> after <code>p[]</code> with index <code>0</code>.</p>