title: c++ overload the [] operator for write/set
body: <p>I have done numerous searches and found a ton of examples and tutorials but still cannot figure out how to get the value when writing to the <code>[]</code> operator... </p>
  
  <p>I feel like i'm going insane.  I must be missing something very simple</p>
  
  <p>as far as i can tell there is a single function for <code>get</code> and <code>set</code> and it looks something like this:</p>
  
  <pre><code>V&amp; operator[](string K);
  </code></pre>
  
  <p>or this:</p>
  
  <pre><code>double &amp;operator[](int n);
  </code></pre>
  
  <hr/>
  
  <p>now great, we can get what is:</p>
  
  <pre><code>a[HERE] 
  </code></pre>
  
  <p>as <code>HERE</code> becomes <code>double &amp;operator[](int HERE);</code>
  and we can easily work with it</p>
  
  <p>but how do we get what is:</p>
  
  <pre><code>a[4] = HERE
  </code></pre>
  
  <hr/>
  
  <p>C# has two very clear get and set methods with the value keyword which represents the object being assigned.</p>
  
  <pre><code>public string this[int key]
  {
      get
      {
          if(key == 1)
             return "1!";
          if(key == 2)
             return "2!";
          else
             return "3!";
      }
      set
      {
          if( value == "setting")   //value is a[3] = THIS
             this.isSet = true;
      }
  }
  </code></pre>