A pointer is a variable which holds the address of the other variables.Pointer are the most striking features of C++ language.At machine level almost every C++ program uses pointers.
Generally There are three main reasons that make pointer so much useful.These are:
1. Pointers provides the facility of directly accessing the memory location of the variables
2. Pointers supports in obtaining memory from the system dynamically.
3. Pointers improve the efficiency of certain functions
Computer memory is composed of several bytes,and every byte has its unique address.So, whatever we store in the memory occupies a certain range of the addresses For example every variable and every function in a program starts at a particular address,and thus every variable has a unique address
These are two types of operators:
1. Address of
2. Value at
The address pointer (&) is used to assign address of a memory location to a variable.
An address of operator represented by a combination & with a pointer Variable.This is used to finding the address of a variable.
j=&i;
Address of i will be stored in the variable j.The data type of j should be pointer type.
The pointer Operator (*) display the value stored at particular address.
A "value -at " operator is represented by an combination of an asterisk (*) with variable name.
int i,*j;
i=45;
j&i;
0 comments:
Post a Comment