C++ whole "operator" keyword all about

What is a whole operator (i.e. surround by space) keyword in C++ about ?
like

class M {};

class N{
 M m;

 operator M() {
  return m;
 }

}

Please explain very clarifying
Thanks before for sincerity

I’m not too sure what “operator” means since I don’t believe it mentioned it in the C++ that is on Codecademy but this is what I was able to find on the web. Hope this helps you.

Google: In programming, an operator is a symbol that operates on a value or a variable . Operators are symbols that perform operations on variables and values. For example, + is an operator used for addition, while - is an operator used for subtraction.

The “operator” term is used for “Operator Overloading”. I’m not to sure on how else it can be used.

For example, lets say you created a class named “Square” that contains a property named “Area”. You then created two objects of class “Square” the first objects “Area” value is set to 10 and the second area is 15.

Square my_square_1;
my_square.Area = 10;

Square my_square_2;
my_square.Area = 15;

Square new_add_square;

Now lets say you wanted to add two objects of the same class “Square” and return it as a new object.
You’d have to overload the “+” by making an operator+ function.


Square Square::overload+(Square squareObject)
{
Square new_Square;
new_square.Area = this->Area + squareObject.Area;

return new_square;
}

new_add_square = my_square_1 + my_square_2;
cout << new_add_square.Area << endl;

hopefully prints out 25