ahmed elbarky ahmed elbarky - 1 month ago 10
C++ Question

modifying a pointer that points to another pointer

Using no other objects besides those already declared, how can
you alter ptrptr so that it points at a pointer to b without
directly touching ptr ?

int a,b;
int *ptr;
int**ptrptr;

ptr =&a;
ptrptr=&ptr;

Answer

You're not allowed to touch directly ptr. So ptr = &b; is not an option.

But this doesn't prevent changing it indirectly. So *ptrptr=&b; would be the way to go.