title: Overload bracket operators [] to get and set
body: <p>I have the following class:</p>
  
  <pre><code>class risc { // singleton
      protected:
          static unsigned long registers[8];
  
      public:
          unsigned long operator [](int i)
          {
              return registers[i];
          }
  };
  </code></pre>
  
  <p>as you can see I've implemented the square brackets operator for "getting".<br>
  Now I would like to implement it for setting, i.e.: <code>risc[1] = 2</code>.</p>
  
  <p>How can it be done?</p>