Pointer In C++:-
In this article I have explained Pointer in c++ in detail with effective way.You will like it , I know about it. So enjoy it lovely friends. The concept of pointer in c++ is most important to get c++ in detail.
It is a variable contains the address of another variable of same type. Pointer is a special type of variable.
If we want to Store the address of ’int’ Type variable then we have to take ‘int’ type of pointer variable.
Pointer Variable Declaration Statement:-
DataType * VariableName;
In this Statement, we declare the data type and the name of a Pointer variable.
Initialization of a Pointer:-
To initialize a Pointer variable, first of all we have to declare the same type of a Simple variable.
Now we have to do initialization of example Pointer,
By above Statement ’ptr’ is initialized,the address of variable ‘a’
If we want to display the value of a then we can write,
By above example it is declared that Pointer ‘ptr’ now indicating the variable ‘a’ and showing the value of a.
//Program to show the use of a pointer.
void main ()
cout<<”the value of variable”<<a;
cout<<” The value of a variable by pointer”<<*ptr;
cout<<”The address of a variable “<<ptr;
The value of variable:-5
The value of a variable by Pointer:-5
The address of a variable:- EH5326 (It may any address)
Address of operator (&):-
The operator is used to get the address of a variable. If we want to get the address of a variable namely ‘a’ then we have to write the following Statement.
After this we put it into the same type of variable of Pointer type.
This operator is used to assign a value to a variable like following Statement.
In (1) Example the value of ‘a’ is going into variable ‘b’ in
(2) example 5 is putting in variable ‘a’.
Pointer To A Pointer :-
A variable declared in a Program is assigned an address. A Pointer variable also has an address. Pointer to a Pointer means that a variable can be declared which can store the address of Pointer variable.
//Program to Show the use of ‘Pointer to a Variable’.
void main ()
int a=10, *ptr1, **ptr2;
cout<<” The value of a variable is:-”<<a<<”in”;
cout<<”The value of a variable by ptr1 is ”<<*ptr<<”/n”;
cout<<”The value of a variable by ptr2 is”<<**ptr2;
I know you will like this post very much.After getting it in your mind please tell me, how it was? Like this post I will provide all stuff like Computer Science , Mathematics , Technology , Meditation etc.
You Also Can See More Result By Using Google Search.
You Also Can Play Online Quiz by following Link,
You Also Can Ask and Give Answer of Questions by following Link,
If you have any requirements to know more about it in detail, then this content may be helpful to you.
You Also Can Visit For More Knowledge In C++:-
Visit Your Website :- www.atozlives.com
“Play With All Computer Science , Mathematics And Technology.”