C++ access component via [""] or [int] for custom class
<p>I've noticed things like what follows in C++.</p>

<pre><code>SomeClass obj = SomeClass();
int boo = obj["foo"];
</code></pre>

<p>What is this called and how can I do it?</p>

<p>example</p>

<pre><code>class Boo {
public:
     int GetValue (string item) {
          switch (item) {
               case "foo" : return 1;
               case "apple" : return 2;
          }
          return 0;
     }
}

Boo boo = Boo();
int foo = boo.GetValue("foo");
// instead of that I want to be able to do
int foo = boo["foo"];
</code></pre>
