how ptr is defererred here and if i use cout<<*ptr
what will happen
How ptr is deferred here
Hello @Bhavit_Singla,
Lets understand with the help of an example:
// variable of int type.
int x;
// assigning some value to it.
x=5;
//Creating a pointer to x.
//It will contain the address of variable x.
int *ptr=&x;
//Printing the value stored at address stored in the pointer variable ptr.
cout<<*ptr;
//Output: 5
Suppose, address of x is 0x12432
and ptr contains 0x12432
so, *ptr will return the value stored at 0x12432
Hope, this would help.
Give a like, if you are satisfied.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.