title: Difference between at() and overloading operator [ ] C++
body: <p>What is difference between <code>at()</code> and overloading <code>operator</code> <code>[ ]</code>? What is distinction in their realization except that <code>at()</code>provides bounds checking and throws an exception <code>out_of_range</code>?</p>
  
  <p>Realization of <code>operator</code> <code>[ ]</code>:</p>
  
  <pre><code> const int LIMIT =100;
   .......................
   int&amp; operator[ ] (int n) const
  
   {
      if(n&lt;0 || n &gt;= LIMIT)
      {
        std::cout&lt;&lt;"Error index!"&lt;&lt;std::endl;
        exit(1);
      }
      return arr[ n ];
   }
  </code></pre>
  
  <p>Can you give an idea of realization <code>at()</code>?</p>