What do you mean by Pointers in C++ language?

A pointer is one of the most important concepts of C++ language. Pointers is a variable that is used to stores the address of another variable in a same program. It look very simple ! But, what do you mean by memory address. As we know every variable which is used in the program have some memory location in the computer system, and that memory location is further unique for every variable. For example, int x=10, means that int is a data type having a user defined name x which store value 10 in it.

int x = 10.
Every variable in C++ have two name, first is user defined name and second is computer generated address. Here x is a user defined address and this is a computer generated address (0x7ffd7b3365ec).
A pointer differs in the way that a pointer is a variable that points to another variable. A pointer holds the memory address of that variable. That variable contains a value. Pointers are also called address variables because they contain the addresses of other variables.

There are two main operators which we can use as pointers operators: 
1. Address operator (  &)
2. Value at operator (*)

int x = 10;

Here a - is a user defined name for a variable.
10 - is a value stored in the variable.
0x7ffd7b3365ec - Memory address generated by computer system.



Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: