ahmed elbarky ahmed elbarky - 1 year ago 80
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;

ptr =&a;

Answer Source

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.