Underscore variable naming convention?

_Value vs Value
_Variable vs Variable
..etc

What does this typically signify? From what I understand this convention is used to signify private variables correct? Or is there a deeper commonly accepted meaning?
Don't hold me to it(I'm still a noob myself) but I believe its just a different variable name is all, to declare a private variable I believe you use private: or something like that, but again, I'm not sure...
If someone knows better, feel free to correct me...
Last edited on
It actually should be avoided completely, since identifiers starting with an underscore are supposedly reserved for compiler usage. So by naming your own identifiers that way, you run the risk of clashing with a compiler reserved keyword.
Don't hold me to it(I'm still a noob myself) but I believe its just a different variable name is all, to declare a private variable I believe you use private: or something like that, but again, I'm not sure...
If someone knows better, feel free to correct me...


Oh no your absolutely right... I just mean i've seen that convention used. You know just like a common practice that people use. Just a way to name your variables so other people kinda know what your doing.

It actually should be avoided completely, since identifiers starting with an underscore are supposedly reserved for compiler usage. So by naming your own identifiers that way, you run the risk of clashing with a compiler reserved keyword.


Ok I see. Yeah I've noticed in some regular C files that it is used a ton. And I've seen it in other examples too but what you say makes sense. Probably a bad practice to pick up.
From what I understand some times an underscore is used after the variable name to suggest that it is a member variable of a class, but as Disch says using an underscore before should be avoided as it can clash with compiler reserved keywords.
Topic archived. No new replies allowed.