title: What is the difference between const string &s and string &s?
body: <p>This is the code from <em>c++ primer</em>:</p>
  <pre><code>string::size_type findChar(const string &amp;s, char c, string::size_type &amp; occurs){
      auto ret = s.size();
      occurs = 0;
      for (decltype(ret) i = 0; i != s.size(); ++i){
          if (s[i] == c){
              if (ret == s.size())
                  ret = i;
              occurs++;
          }
      }
      return ret;
  }
  
  int main () {
      string::size_type ctr;
      cout &lt;&lt; findChar(&quot;hello, world!&quot;, 'o', ctr);
  }
  </code></pre>
  <p>An error happened after removing <code>const</code> from <code>const string &amp;s</code>.</p>
  <blockquote>
  <p>error: cannot bind non-const lvalue reference of type 'std::__cxx11::string&amp;' {aka 'std::__cxx11::basic_string&amp;'} to an rvalue of type 'std::__cxx11::string' {aka 'std::__cxx11::basic_string'}
  cout &lt;&lt; findChar(&quot;hello, world!&quot;, 'o', ctr);</p>
  </blockquote>
  <p>I wonder, in this case, what behaviors of compiler does the <code>const</code> keyword change? Thanks for helping me.</p>