   c++: using parameter names which are the same as member names
  Here's what I want to do in java code:class A{  int varName;  A(int varName){    this.varName = varName;  }}I just want to use the same variable name for both the function parameter and member variable, but still be able to access the member variable. Obviously I can just change the name to m_varName or something, but I don't want to.this.varName = varName;   doesn't work in c++, is there an equivalent?   
  this is a pointer in C++ - your code is failing because you have to use "->" on pointers, not ".".You can either writethis->varName = varName;or(*this).varName = varName;   ;  "this" is a pointer to the instance. Try this->variableName instead of this.variableName.With that said, I hate it when people use the same name. It makes it annoying to read the code.   ;  Assuming we are just talking about constructors, usual form in C++ is to use initialiser lists where possible, in which case the name clash goes away anyway:class A{private:    int varName;public:    A(int varName) : varName(varName) { }};The varName after the colon can only be the member as it makes no sense to initialise a non-member here and the varName in brackets is picked as the parameter by the normal mechanic.Obviously this doesn't apply to non-constructor methods, but unless your class is peppered with setter methods, I find it unusual for these name clashes to occur elsewhere.   