0

what is dereference operator ???😕😕

28th Sep 2016, 9:24 PM
Asma Khan
Asma Khan - avatar
4 ответов
+ 6
Pointers hold memory addresses. You use the dereference operator (*) to actually access what's contained in that address. int x = 5; int *ptr = &x; //ptr points to X. cout << ptr; //This will print X's memory address which is probably useless for you. cout << *ptr; //With the dereference operator you can access what's stored in that address. Therefore this will print 5.
29th Sep 2016, 1:07 AM
ABC
ABC - avatar
+ 5
Dereference operator is the operator that sits ahead of the pointer variable. Suppose we have an integer variable a and an integer pointer pa. The value of a is 7. Then int a = 7; int* pa = &a; Now we can access the value of a using the pointer pa. Like this cout << *pa; This will print 7. Because we used the dereferencing operator (*) before the pointer variable, which means the value of the variable indicated by the pointer. Thanks
28th Sep 2016, 11:38 PM
Md Ishraf Islam
Md Ishraf Islam - avatar
+ 2
thank you guyzz helped alot!!!☺
29th Sep 2016, 7:09 AM
Asma Khan
Asma Khan - avatar
0
Its like acessing data from a save file, i think
8th Oct 2016, 6:01 PM
Rox Has
Rox Has - avatar