I am wondering if it is a good practice to use the same name for both a member variable and a function parameter in C++.
I come from a Java backgro
Do it this way:
class Player
{
public:
void setState(PlayerState *state)
{
this->m_state = state;
}
private:
PlayerState *m_state;
}
You'll thank me some time later on. Haha.. (:
The "m_" ("Member") prefix distinguish members from functions and other stuff. Very useful with stuff like intellisense (or any other IDE auto-suggestion).
Also, mark m_state
as const
if you do not intend to change it later. Just in case.