title: Overloading subscript operator in arrays by reference
body: <p>I have a question about overloading subscript operators by reference, as shown in the following code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;array&gt;
  using namespace std;
  
  class NewArray
  {
      public:
          typedef array&lt;int, 1024&gt; array_type;
          typedef int&amp;             reference;
          reference operator[](const int i) {
              return array_[i];
          }
      private:
          array_type array_;
  };
  
  int main(){
  
      NewArray lhs, rhs;
      rhs[10] = 1000; // Assigning value to rhs[10]
      lhs[10] = rhs[10]; // Arrays references are the same
      rhs[10] = 0; // Modifying reference
  
      cout &lt;&lt; lhs[10] &lt;&lt; " " &lt;&lt; rhs[10] &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>
  
  <p>Given that I'm returning references to the array position, and the lhs[10] and rhs[10] references are equal, shouldn't the output be </p>
  
  <pre><code>0 0
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>1000 0
  </code></pre>
  
  <p>?</p>