C++ Pointers-Concept Explained
C++ pointer or simply a pointer is a simple variable that has the capability to store the memory address of some location.
Lets discuss a small program for illustration:
Lets discuss a small program for illustration:
int * p;
int q=10;
p=&q;
cout<<"Address of q is: "<<p<<endl;
cout<<"Value of q is: "<<*p<<endl;
[*]Here p is a pointer variable and q is a simple interger variable.
[*]& is the address operator. So when we've the statement p=&q, we are actually initializing p with the memory address of q.
[*]As memory addresses are generally of hexadecimal type, so p now also has some hexadecimal value.
[*]p as such has no data type. But int *p means that the data type of the contents of memory location referenced by p (i.e. q) is interger.
[*]So p is also called pointer to integer.
[*]Displaying p will display the memory address of the variable q.
[*]*p displays the content of the memory location it refers to i.e. value of q.
Replies
You are reading an archived discussion.
Related Posts
Hi all
I need your help, I've got two suppliers of Naval brass, the materials are the same from each supplier and a chemical analysis has confirmed this, a hardness...
Pulling off the ultimate career makeover - Fortune Management
www.natural-ui.com, ,Natural User Interface (NUI) is a Swedish innovative emerging technology company specializing in delivering commercially available advanced multi-touch software, hardware and service solutions, to the global market.
[video=youtube;oD-SacHOKqc]https://www.youtube.com/watch?v=oD-SacHOKqc[/video]
Do anybody know the placement procedure of HCL Technologies-server and storage services??
It would be great if you could give me the placement papers of that company.
I desperately need...
Flexible Workstation Suitable For Industrial Cutting, Welding and Drilling
JK Lasers would like to introduce the JK System 5000, a flexible workstation that can be integrated with lasers from both...