Pointers in c++
What is a pointer?
A pointer is a unique variable that holds the address of other variables.
syntax or declaration of pointer ->
pointer_type *pointer_name;
pointer_name = &variable_name;
example:
int main () {
int v=10;
int *p=&v; // & sign means (address of) variable v
cout<<p<<" is the address of the variable"<<endl;
cout<<*p<<endl; // prints the value using pointer
return 0;
}
Comments
Post a Comment