0
what is dereference operator ???😕😕
4 Réponses
+ 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.
+ 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
+ 2
thank you guyzz helped alot!!!☺
0
Its like acessing data from a save file, i think