c++ overloading the [] operator without a class
<p>I have created a structure:</p>

<pre><code>struct a{
   int a1;
   int a2;
   int a3;
};
</code></pre>

<p>Is there any way to create a function where <code>a[1]</code> will give access to <code>a1</code> in the same way that I'll be able through an array?</p>

<p>Edit, I have pasted the part that I actually do:</p>

<pre><code>struct lipid{
  particle mainPart;
  bead * head;
  bead * body;
  bead * tail;
  vec direction;
  bead * operator[](int index){
    switch(index){
    case 0: return head;
    case 1: return body;
    case 2: return tail;
    default: return body;
    }
  }
};
</code></pre>

<p>bead and particle are another struct I have created. It works... thanks</p>
