C++ Operator Classification

Advertisements
Advertisements

The C++ programming language offers different types of operators. These operators are used in expressions that evaluate to a single value. Sometimes the operator is used in decision making that changes the flow of the program.

Here is the diagram that classifies C++ operators into different categories.

C++ Operators Classification
C++ Operators Classification

Arithmetic Operators

OperatorDescription
+Addition operation
Subtraction operation
*Multiplication
/Division operation
%Mod operation ( gives remainder)

Assignment Operators

Operator Description
=Assigns right-value to left-value
+=Assigns ( left-value + right-value) to left-value
-=Assigns ( left-value – right-value) to left-value
*=Assigns ( left-value * right-value) to left-value
/=Assigns ( left-value/ right-value ) to left-value
%=Assigns (left-value % right-value) to left-value
>>=Right-shift and then assign to left-value
<<=Left-shift and then assign to left-value
&=Bitwise AND operation and then assign to left-value
|=Bitwise OR operation and then assign to left-value.
~=Bitwise complement and then assign to left-value

Note: In the following expression A is left-value and 10 is right-value.

A = 10;

Logical Operators

OperatorDescription
<Less than
>Greater than
<=Less than or equal to
>=Greater than or equal to
== Equal to
!=Not equal to
&&AND operation
||OR operation
!NOT operation

Bitwise Operators

OperatorDescription
&Bitwise AND operation
|Bitwise OR operation
^Bitwise Exclusive OR (XOR) operation
>>Bitwise Right Shift
<<Bitwise Left Shift
~Bitwise Complement

Unary Operators

OperatorDescription
*Pointer reference
&Reference to address of a variable
Negative value
!Not operation
~Bitwise complement
++Increment operator
Decrement operator
typeForced conversion to another data type
sizeofSize of a data type in bytes

Bestseller

Let Us C++

One of the best selling book in C++ programming language. A perfect book for beginners and people who want to prefer self-study in step by step manner. Simple and easy narration style made this book very popular. The book assumes that you don’t have programming experience and starts with basic to more advanced topics.

Advertisements
Advertisements
Advertisements