title: Overload bracket access and assignment C++
body: <p>I'm writing a hash table for my data structs class, and I'd like to add a little syntactic sugar to my implementation. </p>
  
  <pre><code>template &lt;typename HashedObj, typename Object&gt;
  Object &amp; Dictionary&lt;HashedObj, Object&gt;::operator[](HashedObj &amp; key)
  {
    return items.lookup(key);
  }
  </code></pre>
  
  <p>That works fine when I do something like cout &lt;&lt; dict["mykey"]. <strong>But how can I do assignment with the brackets?</strong> Something like:</p>
  
  <pre><code>dict["mykey"] = "something";
  </code></pre>
  
  <p>And no, this isn't part of my homework assignment (no pun intended), I just want to learn C++ a little better.</p>