title: C++: No matching function to call to const char
body: <p>im trying to create a object called player in class player.</p>
  
  <pre><code>#include &lt;string&gt;
  #ifndef PLAYER_HH
  #define PLAYER_HH
  
  using namespace std;
  
  class Player
  {
  public:
      Player(string name, int points);
      const string get_name();
      int get_points();
      void add_points(int pts);
      bool has_won();
  private:
      string _name;
  };
  
  #endif // PLAYER_HH
  </code></pre>
  
  <p>from player.cpp:</p>
  
  <pre><code>#include &lt;string&gt;
  
  using namespace std;
  
  Player::Player(string name):
      _name(name), _points(0){
  }
  </code></pre>
  
  <p>Now, the problem is, in the main function i get this error:</p>
  
  <pre><code> error: no matching function for call to ‘Player::Player(const char [6])’
   Player player1 = Player("Matti");
                                  ^
  </code></pre>
  
  <p>Shouldn't the compiler be able to convert it to a string?</p>
  
  <p>edit: Here is the full main.cpp that i'm not supposed to be changing:</p>
  
  <pre><code>#include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include "player.hh"
  
  
  int main()
  {
      Player player1 = Player("Matti");
      Player player2 = Player("Teppo");
      Player* in_turn = 0;
  
      int turn = 1;
      while (true)
      {
          if (turn % 2 != 0)
          {
              in_turn = &amp;player1;
          }
          else
          {
              in_turn = &amp;player2;
          }
  
          std::cout &lt;&lt; "Enter the score of player " &lt;&lt; in_turn-&gt;get_name()
               &lt;&lt; " of turn " &lt;&lt; turn &lt;&lt; ": ";
          int pts = 0;
          std::cin &gt;&gt; pts;
  
          in_turn-&gt;add_points(pts);
          if (in_turn-&gt;has_won())
          {
              std::cout &lt;&lt; "Game over! The winner is " &lt;&lt; in_turn-&gt;get_name() &lt;&lt; "!" &lt;&lt; std::endl;
              return EXIT_SUCCESS;
          }
  
          std::cout &lt;&lt; std::endl;
          std::cout &lt;&lt; "Scoreboard after turn " &lt;&lt; turn &lt;&lt; ":" &lt;&lt; std::endl;
          std::cout &lt;&lt; player1.get_name() &lt;&lt; ": " &lt;&lt; player1.get_points() &lt;&lt; "p" &lt;&lt; std::endl;
          std::cout &lt;&lt; player2.get_name() &lt;&lt; ": " &lt;&lt; player2.get_points() &lt;&lt; "p" &lt;&lt; std::endl;
          std::cout &lt;&lt; std::endl;
  
          turn += 1;
      }
  
      return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>You guys are awesome with your fast answers :-)</p>