Professional Documents
Culture Documents
POINTER
POINTER
Pointer
• Definition:
A pointer is a variable whose value is the address of another
variable.
addr
Dereference operator (*)
newvar
This could be read as: “newvar equal to value pointed to by p", and the
statement would actually assign the value 25 to newvar, since p is 1776, and
the value pointed to by 1776 (following the example above) would be 25.
• Example:
int *p;
int var, newvar, newvar1;
var = 25;
p = &var;
newvar1 = p;
newvar = *p;
cout<<b<<endl<<*q<<endl;
int x, y;
int *p = &x, *q = &y;
*p = 35;
*q = 98;
*p = *q;
Cout<<x<<“ “<<y<<endl;
Cout<<*p<<“ “<<*q<<endl;