previous | start | next

Operator Overloading

In C++, it is possible to overload operators in addition to overloading functions.

For example, we can overload the + operator with some restrictions.

An example restriction is that you can't overload the meaning of operators for basic types (non-class types) like int, float, double, char, etc.

So you can't make 4 + 2 be 42 or any other arbitrary value other than 6.

You can overload operators if one or more of the operands is of class type.



previous | start | next