title: How to set cin to a member function of a class in C++?
body: <p>I am making a small console game and I have a <code>player</code> class with private integers for the stats and a private string for the name. What I want to do is to ask the user for their name, and store that into the private <code>name</code> variable in the <code>player</code> class. I got an error stating:</p>
  
  <pre><code>error: no match for 'operator&gt;&gt;'   
  (operand types are 'std::istream {aka std::basic_istream&lt;char&gt;}' and 'void')
  </code></pre>
  
  <p>Here is my code:</p>
  
  <p><strong>main.cpp</strong></p>
  
  <pre><code>#include "Player.h"
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  int main() {
  
      Player the_player;
      string name;
      cout &lt;&lt; "You wake up in a cold sweat. Do you not remember anything \n";
      cout &lt;&lt; "Do you remember your name? \n";
  
      cin &gt;&gt; the_player.setName(name);
      cout &lt;&lt; "Your name is: " &lt;&lt; the_player.getName() &lt;&lt; "?\n";
  
      return 0;
  }
  </code></pre>
  
  <p><strong>Player.h</strong></p>
  
  <pre><code>#ifndef PLAYER_H
  #define PLAYER_H
  #include &lt;string&gt;
  using namespace std;
  
  class Player {
  public:
      Player();
      void setName(string SetAlias);
      string getName();
  
  private:
      string name;
  };
  
  #endif // PLAYER_H
  </code></pre>
  
  <p><strong>Player.cpp</strong></p>
  
  <pre><code>#include "Player.h"
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  
  Player::Player() {
  
  }
  
  void Player::setName(string setAlias) {
      name = setAlias;
  }
  
  string Player::getName() {
      return name;
  }
  </code></pre>