title: Why doesn't c++ recognize a string when trying to convert it into another type?
body: <p>I have a fairly simple class that looks like this:</p>
  
  <pre><code>class Person {
      public:
  
          Person(string name): _name(name) {};
  
          void greet(const Person&amp; person) const {
              cout &lt;&lt; "Hello, " &lt;&lt;  person._name &lt;&lt; "!" &lt;&lt; endl;
          };
  
      private:
          string _name;
  };
  </code></pre>
  
  <p>Note that the <code>greet</code> method takes a parameter of the <code>Person</code> type. When I pass it a <code>Person</code> object, it works as expected. Now let's pass it a <code>string</code> as a parameter in this way:</p>
  
  <pre><code>Person maher("maher");
  maher.greet("sam");
  </code></pre>
  
  <p>When trying to run that code in QT (on a machine running ubuntu), it generates the following error:
  <code>no matching function for call to ‘Person::greet(const char [4])’</code></p>
  
  <p>I was able to resolve this error by casting the string in this way: <code>maher.greet(string("sam"));</code></p>
  
  <p>My question is the following: Why can't c++ <em>'see'</em> that I'm passing a string to the <code>greet</code> method? Does it have anything to do with the fact that the <code>greet</code> method accepts a <code>Person</code> object?</p>