Unary operators in C++

Unary operators in C++

Unary operators in C++

Unary operators in C++ are those operators which have single operand. They are of following types:

1. Unary Plus (+)

This operator specifies that a number is positive. It is optional to put this operator before a number as a number without sign is considered positive automatically.

Example: +14, 45

 2. Unary Minus (-)

This operator makes a number negative.

Example:  -1, -455

 3. Pointer Operator (*)

This operator can be used to declare a pointer variable .


int *p;

**Above Example declares a pointer variable p .

 4. Address operator(&)

This operators basically refer to location of a variable in memory.


int n=20,*p;

**Above example assigns  the address of variable n into pointer variable p.

5. Increment operator (++)

6. Decrement operator (–)

Spread the love
Lesson tags: address operator in C++, decrement in C++, increment in C++, pointer operators in C++, unary minus in C++, unary plus in C++
Back to: C++ Programming Notes
Spread the love