What are Pointers?
A pointer is simply a variable that holds a memory address. When a variable is declared, the address of some location in memory, is where the value of the variable is stored. I’ll show you what I’m talking about. In this simple application, I will declare a variable and show you its memory address.
 | |  | | |
#include <iostream.h>
int main()
{
int n; //variable
cout <<"Here is the address of n: " << &n << endl;
return 0;
} |
|  |
|
Here we see a new operator, its called the address operator(&). The address of a variable is accessed by means of the address operator. As you can see, we used it here:
this prints the address of n. The address, 0x0065FDF4 was returned on my computer. Other systems will probably give a different address. Usually programmers don’t need to know the address of the variable, but if they do, just use the & operator! We will be getting more indeph using the address(&) operator shortly.Please Rate this Code:
Comments for: What are Pointers?
There are NO user contributed comments for What are Pointers?.
|
 |
|
 |