Ambiguous Operators
Previous Topic  Next Topic 

It can be seen from the above tables that the three symbols


        & - *


can each stand for two different operators, depending on how the symbol is used.   One usage is as a binary operator, where two different values are combined into one. The other usage is as a unary operator, where a single value is changed to a new value.


The context that the operator is used in (unary or binary) defines the meaning of these symbols in each situation, thus clearing up any ambiguity.


The meaning of these symbols in each situation is:


Symbol

Example

Meaning

Unary -

-A

Change sign of A

Unary &

&A

Pointer to variable A

Unary *

*A

The variable pointed to by A

Binary -

A B

Subtract B from A

Binary *

A * B

Multiply A and B

Binary &

A & B

Concatenate strings A and B