title: C++ Find Function Compile Error With std::string
body: <p>I've been reading Stroustrup's "The C++ Programming Language" to learn how to program in C++, but the following example code from the text book doesn't seem to compile correctly.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iterator&gt;
  
  int main()
  {
   std::string s = "Hello!";
   char c = 'l';
   std::cout &lt;&lt; "The number of " &lt;&lt; c &lt;&lt; "\'s in the string " &lt;&lt; s &lt;&lt; " is " &lt;&lt; count(s,c);
  }
  
  int count(const std::string&amp; s, char c)
  {
      std::string::const_iterator i = std::string::find(s.begin(), s.end(), c);
      int n = 0;
      while(i != s.end())
      {
          ++n;
          i = std::find(i+1, s.end(), c);
      }
  
      return n;
  }
  </code></pre>
  
  <p>These are the compile errors:</p>
  
  <pre><code>main.cpp:8:92: error: ‘count’ was not declared in this scope
        std::cout &lt;&lt; "The number of " &lt;&lt; c &lt;&lt; "\'s in the string " &lt;&lt; s &lt;&lt; " is " &lt;&lt; count(s,c);
                                                                                              ^
  main.cpp: In function ‘int count(const string&amp;, char)’:
  main.cpp:13:80: error: no matching function for call to ‘std::basic_string&lt;char&gt;::find(std::basic_string&lt;char&gt;::const_iterator, std::basic_string&lt;char&gt;::const_iterator, char&amp;)’
           std::string::const_iterator i = std::string::find(s.begin(), s.end(), c);
  </code></pre>
  
  <p>What is wrong with my code?</p>