Overloadable Operators

Let’s see the operators in D that can be overloaded.

We'll cover the following

There are different kinds of operators that can be overloaded.

Unary operators

An operator that takes a single operand is called a unary operator:

++weight;

++ is a unary operator because it works on a single variable.

Unary operators are defined by member functions named opUnary. opUnary does not take any parameters because it uses only the object that the operator is being executed on.

The following are the overloadable unary operators and their corresponding operator strings:

Get hands-on with 1000+ tech skills courses.