Currently, the + operator is used to add two numbers or concatenate two strings together. Using Operator Overloading we can also modify it to perform some operations on our newly created objects.
To overload the + operator, we have to overwrite the internal __add__
method of the operand's class. It is a method that is present by default in every class.
In the example above, we have the House class which overwrites the __add__
method. It accepts a parameter room. This allows us to add rooms to the house using the + operator, as shown above.