title: Is it safe to overload char* and std::string?
body: <p>I have just read about the overloading functions on a beginner book. 
  Just out of curiosity I 'd like to ask whether it is safe to overload between char* and std::string. </p>
  
  <p>I played with the below code and get some result. But I was not sure whether it is an undefined behavior. </p>
  
  <pre><code>void foo(std::string str) {
    cout &lt;&lt; "This is the std::string version. " &lt;&lt; endl;
  }
  
  void foo(char* str) {
    cout &lt;&lt; "This is the char* version. " &lt;&lt; endl;
  }
  
  int main(int argc, char *argv[]) {
  
    foo("Hello"); // result shows char* version is invoked
  
    std::string s = "Hello";
    foo(s); // result shows std::string version
  
    return 0;
  
  }
  </code></pre>