In C ++, you can if you want:
struct A { int x; A(int x) : x(x) { foo(this->x);
Although I also often use stylistic names for members (e.g. _x ), I do this for non-public members. If x is publicly available, as in this example, I would do it this way and look at renaming the ctor parameter if I thought it would be more readable.
Edit: Since people seem to be distracted, I will clarify on _x . The standard reserves several identifier names:
- any name with two adjacent underscores in any namespace
- any name with a leading underscore followed by an uppercase letter in any namespace
- any name with a leading underscore in the global area
Since members are limited to a class, they do not fall into the third category. Nevertheless, it would be nice not to be distracted. :) Feel free to ask a question about reserved identifiers in C ++ and post a link to it in the comments if you want.
Roger Pate
source share