Pertaining to the this
pointer, I wanted someone's opinion whether the below 2 snippets of code implement the same functionality or not.
Position Position::operator = (Position pos)
{
this->x = pos.x;
this->y = pos.y;
return *this;
}
Position & Position::operator = (Position pos)
{
this->x = pos.x;
this->y = pos.y;
}
I know that the 1st snippet is more commonly used. However, I want to confirm if the 2nd snippet does the same functionality as I am passing a reference to the this
object using &
.