Search This Blog

Tuesday, 30 October 2012

C++ operators

C++ Operators: 
  •  Arithmetic
  •  Assignment 
  •  comparison & logical operator
           -logical
           -Equality
           -Relational
  • Bitwise logical operators
           -Unary operators
           -Ternary operators
           -Comma operators
           -Scope resolution operator
           -New and delete
           -Other operator
  • Special operator
Arithmetic Operator:
 The arithmetic operators are called as binary operators
    +,-,*,/,%,=
Table of Arithmetic operators 

Operator NamesyntaxCan overloading
Basic assignment     a=byes
Addition             a+bYes
Subtraction          a-bYes
Unary plus           +a  Yes
Unary minus          -a  Yes
Multiplication       a*bYes
Division             a/bYes
Module               a%bYes

Comparision & logical operators:

a)Relational operators
    <, >, <=, >= 
 b)Equality operators
    ==, !=
 c)logical operators
    &&,||,!




Operator Name syntax Can overloading
Equal to                 a==byes
Not equal to             a+b  Yes
Greater than             a-b  Yes
Less than                +a   Yes
Greater than or equal to -a   Yes
less than or equal to    a*b  Yes
Logical negation         a/b  Yes
Logical AND              a%b  Yes
Logical OR               a||b Yes

Bitwise logical operators:


Operator Name syntax Can overloading
Bitwise NOT         ~a   yes
Bitwise AND         a&b  Yes
Bitwise OR          a|b  Yes
Bitwise XOR         a^b  Yes
Bitwise left shift  a<<b Yes
Bitwise Right shift a>>b Yes

Compound assignment operators:


Operator Name syntax Meaning   Can over loading  
Addition assignment            a+=b  a=a+b  Yes
Subtraction assignment         a-=b  a=a-b  Yes
Multiplication assignment      a*=b  a=a*b  Yes
Division assignment            a/=b  a=a/b  Yes
Modula assignment              a%=b  a=a%b  Yes
Bitwise AND assignment         a&=b  a=a&b  yes
Bitwise OR assignment          a|=b  a=a|b  Yes
Bitwise XOR assignment         a^=b  a=a^b  Yes
Bitwise left shift assignment  a<<=b a=a<<b Yes
Bitwise Right shift assignment a>>=b a=a>>b Yes

Special Operator:
  • Unary operators
  • Ternary operators
  • Comma Operators
  • Scope resolution Operators
  • New and delete Operators
  • Other Operators
Unary Operator:
  1. * concern of the storage feild to which a pointer is pointing
  2. & ambrassion is a address of variable
  3. - negative value
  4. ! negation
  5. ~ Bitwise complemental
  6. ++incremental
  7. --decremental
  8. size of data type in bite.
Ternary Opetators
exp1; exp2; exp3;
(eg) 
              a   b
   max=(a>b)?<->;<->;
    |         ^   ^ 
          V___________ |_____|

If (a>b)
max =a
else
max =b

Comma Operator:
 A separator in the variable declaration

Scope resolution Operator:
 Used in a class number function defenition

New and delete Operator:
 Allocate and deallocated the memeory

Other Operator (or) paratheses:
 For grouping expression

Membership Operator:(->):
 Represent the variables in structure and union.






























No comments:

Post a Comment