title: C++ using square brackets with pointer to instance
body: <p>I've created a singleton class which uses <code>GetInstance()</code> method to get the instance address (pointer).
  Inside the class i have an array of unsigned long int which i've created the <code>operator []</code> for it (direct access to the array).
  How can i use the pointer i got from <code>GetInstance</code> in order to use the <code>[] operator</code> ?
  I've tried :</p>
  
  <pre><code>class risc { // singleton
  protected:
  unsigned long registers[8];
  static risc* _instance;
  risc() {
      for (int i=0;i&lt;8;i++) {
          registers[i]=0;};
      }
  public:
  unsigned long   operator   [](int i) const  {return registers[i];}; // get []
  unsigned long &amp; operator   [](int i)        {return registers[i];}; // set []
  static risc* getInstance() { // constructor
          if (_instance==NULL) {
              _instance=new risc();
          }
          return _instance;
      }
  };
  
  risc* Risc=getInstance();
  *Risc[X]=...
  </code></pre>
  
  <p>But it doesn't work ... is there a way i can use the brackets to access the array directly using the class pointer ?</p>
  
  <p>Thanks !</p>