Should I use the same name for a member variable and a function parameter in C++?

前端 未结 9 1803
自闭症患者
自闭症患者 2020-12-08 03:08

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

9条回答
  •  Happy的楠姐
    2020-12-08 03:45

    I would suggest you to follow some coding style convention. Personally I use the:

    class Player
    {
        public:
        void setState(PlayerState *state)
        {
            _state = state;
        }
    
        private:
           PlayerState* _state;
    }
    

提交回复
热议问题