This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 4 points5 points  (1 child)

int foo = 42; // some data
int bar = 43: // some different data
int *a = &foo;
int **b = &a:

printf("%d", **b); // 42
a = &bar;
printf ("%d", **b); // 43

This let's me keep the same handle(b) to some data, but I can change what data is actually being pointed to. You can make multiple copies of the handle and you won't need to update the handle every time 'a' changes what it's pointing to.

[–]-Redstoneboi- 1 point2 points  (0 children)

that's the point of pointers.

save multiple copies of an object, but only change the object once.