what does "this->variableName" mean

below is the Arduino Stepper.cpp I'm looking through, and just wondering what the "this->" is all about in front of a bunch of the variable names. Is it a naming convention or doing something I'm missing?

Stepper::Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2)
{
  this->step_number = 0;      // which step the motor is on
  this->speed = 0;        // the motor speed, in revolutions per minute
  this->direction = 0;      // motor direction
  this->last_step_time = 0;    // time stamp in ms of the last step taken
  this->number_of_steps = number_of_steps;    // total number of steps for this motor
  
  // Arduino pins for the motor control connection:
  this->motor_pin_1 = motor_pin_1;
  this->motor_pin_2 = motor_pin_2;

  // setup the pins on the microcontroller:
  pinMode(this->motor_pin_1, OUTPUT);
  pinMode(this->motor_pin_2, OUTPUT);
  
  // When there are only 2 pins, set the other two to 0:
  this->motor_pin_3 = 0;
  this->motor_pin_4 = 0;
  
  // pin_count is used by the stepMotor() method:
  this->pin_count = 2;
}

It's one way C++ allows you to access member variables (variables that are part of an object). "this" is actually a pointer to the object's current location in memory (in this case, of type Stepper*), so doing "this->(some variable)" is one way to get the value of (some variable).

If you open up the corresponding header file, probably Stepper.h, you'll see each variable that comes after the "this->" declared in the class body.

It's a shorthand notation, often used with structures and classes. For example:

void setup() { 

  Serial.begin(9600); 
} 

void loop() { 

  struct aStructure{
    int i;
    char temp;
  } myStruct;
   aStructure* ptr;
 
  myStruct.i = 10;
  
  ptr = &myStruct;
  Serial.print("(*ptr).i = ");  
  Serial.println((*ptr).i);
  Serial.print("ptr->i = ");  
  Serial.println(ptr->i);

}

If you run the code, both the (*ptr).i and ptr->i yield 10 on the monitor.

this-> often appears in code because the developer chose a poor name for the member variable and the corresponding name for the method argument.

If the class contains a member called speed, and a method called setSpeed(int speed), and the implementation looks like:

Stepper::setSpeed(int speed)
{
}

then the only way to distinguish between the member speed and the argument speed is to use this->:

   this->speed = speed;

Of course, it would, in my opinion, be better to use different names:

Stepper::setSpeed(int newSpeed)
{
   speed = newSpeed;
}

There are a few places where this is useful. With -> after it, rarely.