The pointer, as the name suggests, is something which is pointing to or directing to something. The pointer is used to store the address of another variable and the data type of the pointer is same as data type of variable it is pointing to. As the variable which points to other variable is called pointer and the variable which is pointed to by the pointer is called pointee. We represent the relation between the two as:
We can also have pointer to pointer and we declare it as:
Int **z;
z=&y;
And the memory map can be represented as:
int* x;
int* y;
int i;
int j;
Memory map at this moment is as:
x=&i; // the statement assigns the pointee i to pointer x or we can say address of i is stored in variable x.
*x=2; // the pointee of x gets the value 2. This statement is equivalent to i=2;
Memory map at this moment is as:
*y=4// ERROR as no pointee is assigned
Remember that using pointers, we need to do two tasks: one creating a pointer and other as assigning a pointee to pointer. In the above example one task was done and hence the ERROR.
y=x; // this statement assigns the pointee of x to y also. Hence pointee of both x and y are same.
Memory map at this moment is as:
*y=4; //As pointee for both x and y are same. Hence changing the value of one would change the same for other.
Memory map at this moment is as:
y=&j;// Now pointer y is assigned a new pointee j.
Memory map at this moment is as:
Hence now both pointers points to different memory locations.
*y=8;
Memory map at this moment is as:
*y=x; // gives an ERROR as data types don’t match. x is not an int but pointer to int
x=*y; // gives ERROR again as *y is not Int* but int. In other words *y is not a pointer but a Int value while x is int* i.e. pointer to int.
*y=i; // both the data types are same INT and hence value of i is assigned to pointee of y.
i=7; // value of i is changed i.e. pointee of x is changed
Memory map at this moment showing result of above 2 statements is as:
x=y; // both x& y are int* i.e. pointers. Now both pointers point to same place and previous pointee of x retains the value.
Memory map at this moment is as:
Alguns arquivos de fotos particulares que você exclui do telefone, mesmo que sejam excluídos permanentemente, podem ser recuperados por outras pessoas.