6. Relational Operators
Operator Usage
== x==y x equal to y
!= x!=y x not equal to y
> x>y x greater than y
< x<y x lesser than y
>= x>=y x greater than (or) equal to y
<= x<=y x lesser than (or) equal to y
7. Logical Operators
Operator Usage
&& Exp 1 && Exp 2 Logical AND (Return true if both are true)
|| Exp 1 || Exp 2 Logical OR (Return true at least one true)
! ! Exp 1 Logical NOT (Return true if Exp false)
8. Bitwise Operators
Operator Name
& Binary AND
| Binary OR
^ Binary XOR
~ Binary One’s Complement
<< Binary Shift Left
>> Binary Shift Right
30. Pointers
What is pointer?
Pointer reduces the code and improves the performance, it is used to retrieving strings,
trees etc. and used with arrays, structures and functions.
We can return multiple values from function using pointer.
It makes you able to access any memory location in the computer's memory.
32. Usage of Pointer
Dynamic memory allocation
In c language, we can dynamically allocate memory using malloc() and calloc() functions
where pointer is used.
Arrays, Functions and Structures
Pointers in c language are widely used in arrays, functions and structures. It reduces the
code and improves the performance.
33. Declaring a Pointer
We use the asterisk (*) symbol to designate a variable as a pointer in C++. The
asterisk symbol can be placed anywhere before the pointer name and after the
datatype.
Syntax :
If we have to declare two (or more) pointers together in the same line, we will need
to use the asterisk symbol before each variable name. For example:
36. Double Pointers
What is double pointers?
Regular pointer is to refer to an object in memory, then a double pointer is a variable that points to
another pointer which in turn, points to an object in memory.
Double pointer is also known as pointer to pointer.
37. Declaring Double Pointers
Declaring a Pointer to a Pointer in C++ or double-pointer is very similar
to declaring a single pointer; the only difference is that an extra * is
added.
For Example
Syntax :
39. New & Delete Operator
The “new” operator is used to allocate memory for a
variable or any other entity like objects or arrays on a
heap memory area. If a sufficient amount of memory
is available on the heap, the new operator will
initialize the memory and return the address of the
newly allocated memory and you can use pointers to
store the address of that memory location.
Output
Example
Since the programmer has allocated memory at
runtime, it’s the responsibility of the programmer to
delete that memory when not required. So at any
point, when programmers feel a variable that has
been dynamically allocated is no anymore required,
they can free up the memory that it occupies in the
free store or heap with the “delete” operator. It
returns the memory to the operating system. This is
also known as memory deallocation. Also, memory
40. Class
Description & Structure :
A class is a blueprint for the object.
We can think of a class as a sketch (prototype) of a house. It contains all the details about the floors,
doors, windows, etc. Based on these descriptions we build the house. House is the object.
41. Objects
Description & Structure :
When a class is defined, only the specification for the object is defined; no memory or storage is
allocated.
To use the data and access functions defined in the class, we need to create objects.