 <pre><code>const char&amp; operator[](std::size_t position) const </code></pre> <p>would prevent that, except if the user of the code used <code>const_cast</code> to remove the <code>const</code>.</p> <p>Adding <code>const</code> means that the data that the reference refers to can't be changed</p>