Preview
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 .
Example
int *p;
**Above Example declares a pointer variable p .
4. Address operator(&)
This operators basically refer to location of a variable in memory.
Example:
int n=20,*p; p=&n
**Above example assigns the address of variable n into pointer variable p.
5. Increment operator (++)
6. Decrement operator (–)
Popular Books of Computer Science