/
Operator Overloading

Operator Overloading

C++ allows you to write custom behaviors for operators like +, -, & → etc. in the language.

Generally speaking for application code this is a bad idea since it makes it hard to understand when a custom method or function is being called. For very limited library applications it can be helpful.

For instance if you had a library for doing matrix operations, one could overload the + and * operations to define matrix addition and multiplication.

We use operator overloading for smart pointers in our code base.

Related content

Smart Pointers
Smart Pointers
More like this
Operators
More like this
Functions
More like this
What are classes and methods in C++?
What are classes and methods in C++?
More like this
Arithmetic Operators
Arithmetic Operators
More like this
What is C++ name mangling?
What is C++ name mangling?
More like this