Types of Operators in C++

An expression consists of variables and constants separated by Operators in C++. There are mainly 8 types of Operators in C++ are given as follows :

1. Arithmetic Operators
2. Relational Operators
3. Logical Operators
4. Increment and decrement operators
5. Pointer Operators
6. Assignment Operators
7. Bitwise Operators
8. Misc Operators

Arithmetic Operators : Arithmetic Operators are used to perform arithmetic operations.

Relational Operators : Relational Operators are used to compare the values of operands to produce a logical value. It is a type of bool so, a logical is either true or false.

Logical Operators : Logical Operators combine two or more relational operators or expressions and produce a logical value or results.
Example :

x>y && x==5
x==5 || y==7

Increment and decrement operators : Increment operator (++) is used to increase the value of an integer or char variable by 1. Decrement operator (- -) is used to reduce the value of an integer or char variable by 1
x = 15;
x++ or ++x will produce the result x = 16
x = 15;
x- – or – -x will produce the result x = 14

Pointer Operators : Pointer Operators produces address values.
Example :

where a is a variable and ptr is a pointer.

Assignment Operators : In C++, there are three types of Assignment Operators are given as below :
(i) Chained Operators : A chained operator is used for instance variable at the time of declaration. It can’t be used to initialize variables.


(ii) Embedded Operators :

(b=10) is an assignment operator that is known as Embedded Operator, 
Here the value 10 is assigned to b and then the result 10+5=15 is assigned to a.

(iii) Compound Operators : In C++, the compound operator is a combination of the assignment operator with a binary arithmetic operator.

The operator += is known as Compound Assignment Operator.

Bitwise Operators : Bitwise Operators are used to manipulate data at bit level. They are basically used for testing or shifting bits.
Example :

a<<4   // shift four bit position to left
b>> 2  // shift two bit position to right