You have two main options: Skip the pointer or follow the link. To follow the pointer, a pointer to a pointer is required:
void modify_pointer(node **p) { *p = new_value; } modify_pointer(&d);
When following the link, & used:
void modify_pointer(node *&p) { p = new_value; } modify_pointer(d);
If you pass the pointer as soon as node *d , then changing d inside the function will only change the local copy, as you noticed.
source share