How does rhs work?

The compiler doesn’t know that rhs stands for “right hand side”, and in fact the name of that variable can be anything you like.

The compiler “knows” how to format this because the syntax of operator= requires it to be this way.

class A
{
public:
   A& operator=(const A& other);
};

The language defines the usage of this operator to take the form:

A a, b;
a = b;

The code above calls A::operator=(const &other) against the instance of A named a, and uses the instance of A named b as other.

Leave a Comment