C++ Operators and Expressions: Arithmetic Operator, Assignment Operator, Comparison Operator, Relational Operator, Equality Operator, Logical Operator, Bitwise Operator, Special Operator, Unary Operator, Ternary Operators

C++ Operators and Expressions
(i) Arithmetic Operators: (+, -, * , / , %)
(ii) Assignment Operators: (=, += , - = , *= , /=, %=)
(iii) Comparison and Logical Operators:
(a) Relational Operators (< , >, <= , >=)
(b) Equality Operator (==, !=(not equal to))
(c) Logical Operator (&& , || , ! )
(iv) Bitwise logical Operators:
& Bitwise AND
^ Bitwise XOR
| Bitwise OR
>> Bitwise right shift
<< Bitwise left shift
~ Bitwise complement
(v) Special Operators
(a) Unary Operator
* contents of the storage field to which a pointer is pointing.
& Address of variable.
- Negative Value.
! Negation (0 , if value is not equal to 0, 1 , if value=0)
++ Increment
-- Decrement
//type Forced type of conversion
sizeof size of the subsequent data type or type in byte
(b) Ternary Operato. r (?:)
exp1 ? exp2 : exp3
Eg max= ( first > second) ? first : second;
(c) comma operator ( , )
(d) Scope operator ( : : )
The double colon : : operator is used as the scope resolution operator in C++.A member function of the class is defined using the : : scooping operator.
Eg. #include<iostrean.h>
#include<conio.h>
int a=10;
void main()
{ int a=5;
cout<<a; // 5
cout<<: :a; // 10
}
#include<iostrean.h>
#include<conio.h>
class sample
{
public:
void input();
}
//return type of func classname: :memfunction
void sample : : input();
(e) new and delete operators: In traditional C the dynamic memory allocation and deallocation are through library functions such as malloc, alloc, calloc and free. C++ defines a new method for carrying out memory allocations and deallocations i.e. using new and delete operators.
(f) Other operators
(a) Parenthesis for grouping expressions( () ).
(b) Membership operators ( [ ] , )
Labels: C++