title: Array operator [] overloading const and non-const versions
body: <p>I got an assignment to implement a template array class.
  One of the requirement is to overload the [] operator.
  I made this two const and non-const version which seems to be working fine.</p>
  
  <pre><code>const T&amp; operator[](const unsigned int index)const
  </code></pre>
  
  <p>and</p>
  
  <pre><code>T&amp; operator[](const unsigned int index)
  </code></pre>
  
  <p>My question is how will the compiler know which one to run
  when i will do something like:</p>
  
  <pre><code>int i=arr[1]
  </code></pre>
  
  <p>On a non-const array?</p>