title: Should I use the same name for a member variable and a function parameter in C++?
body: <p>I am wondering if it is a good practice to use the same name for both a <em>member variable</em> and a function <em>parameter</em> in C++.</p>
  
  <p>I come from a Java background, where this was common. I am wondering if in C++ there are drawbacks doing the following (the code works):</p>
  
  <pre class="lang-cpp prettyprint-override"><code>class Player
  {
      public:
      void setState(PlayerState *state)
      {
          this-&gt;state = state;
      }
  
      private:
         PlayerState *state;
  }
  </code></pre>
  
  <hr>
  
  <p>Thank you for the answers. As I understand while it works, a better practice would be to put some kind of marker to differentiate member variable from function parameters like: </p>
  
  <pre><code> _ or m_
  </code></pre>
  
  <p>In some editors (like Qt Designer), member variables are shows in a different color. This is why it did not seem necessary to add any prefixes.</p>