1
vecteur& vecteur::operator+=(const vecteur& autre)
{
    x += autre.x;
    y += autre.y;
    z += autre.z;
    return *this;
}

What does *this mean in that case?

Is there any possibility to call it differently, like simply return vecteur?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770

1 Answers1

2

this is a pointer to the object that the method is being called on. *this is that pointer being dereferenced (i.e. accessing the actual object itself).

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Nasrat Takoor
  • 344
  • 3
  • 8