title: How do I access a C++ subscript operator from within the class in which it resides?
body: <p>Where, ClassA has an operator as such, that returns ClassB:</p>
  
  <pre><code>class ClassA
  {
  public:
      ClassA();
      ClassB &amp;operator[](int index);
  }
  </code></pre>
  
  <p>If I want to access said operator from within ClassA's constructor, as so:</p>
  
  <pre><code>ClassA::ClassA()
  {
      // How do I access the [] operator?
  }
  </code></pre>
  
  <p>At the moment, as a work-around I'm just using a method called GetAtIndex(int index) which the [] operator calls, and so does the constructor.</p>
  
  <p>It would be nice if I could access it in the same as as C# works:</p>
  
  <pre><code>// Note: This is C#
  class ClassA
  {
     ClassB this[int index]
     {
         get { /* ... */ }
         set { /* ... */ }
     }
  
     void ClassA()
     {
         this[0] = new ClassB();
     }
  }
  </code></pre>
  
  <p><strong>Note:</strong> I'm using g++</p>