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

前端 未结 9 1826
自闭症患者
自闭症患者 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 03:51

    Please note that some compilers (vs 2015) may generate a warning if a variable shadows another. Off course, one can disable these kind of warnings. But I think it is good practice to have these checks enabled.

提交回复
热议问题