[Solved] please explain this-> in c++ [duplicate]


this keyword is used to reference current instance of given class, for example:

class A {
   public:

       void setName(std::string name) {
           // if you would use name variable directly it 
           // will refer to the function parameter, 
           //hence to refer the field of the class you need to use this
           this->name = name;
       }
   private:
       std::string namel
}

solved please explain this-> in c++ [duplicate]