+ 5
why we need to define that a pointer is pointer to pointer of pointer?
size of pointer is fixed &the basic purpose to define type of pointer is that we could be able to dereference it. int* a; int** b=&a i can understand that a points to address of int. and b points to address of a & we could dereference it. but now i want to point a pointer address of b i need to do something like - int*** c=&b why its so i mean we know size of pointer is fixed so why do we need to define that whether its pointer to pointer or pointer to pointer of pointer We will dereference it the same way
2 odpowiedzi
0
Because it is not the same. Every layer of pointers is another jump away from the original variable. If it all evaluated back to the original variable it wouldn't be a pointer to a pointer anymore, it would be a pointer to a variable. A pointer allows you to assign a variable to a new set of contents while keeping the old contents where they are, hence memory leaks.