Why use pointers to pointers?

Pretty much what it sounds like. I know that using pointers is obviously quite useful in C++, but Ive never understood what the use of pointers to pointers could be. Wouldn't it just waste memory defining the adresses at the pointer to pointer level? Is there a hidden use for them, or was it just included for the sake of flexibility in C++?

Usually a pointer to a dynamically allocated array ends up being a pointer to a pointer, or a bunch of pointers in that case. MS's COM does this A LOT which is probably the most difficult part about it to wrap your head around. I've also caught myself doing it while I was playing around with Polymorphism too, you start out with an array of pointers to base objects, you find yourself wanting to pass it to a function and before you know it you end up dereferencing objects in order to dereference them.

If you wanted to write a function that added to the stack, you need that function to do two things. The first is of course to create the new node and put it on the top of the stack. The second is that the my_stack pointer would have to now point to the new node. This means that you would not be able to pass my_stack by value, you would need to pass a pointer to my_stack ( which is a pointer )

You'd use a pointer to a pointer for the same reasons you'd use a pointer to any other data type. For example, you might want to pass a pointer into into a function that changes the value of that pointer, and you might have a reason to prefer using a pointer to the pointer, rather than a reference to it.

Or you might want to have an array of pointers, just like you might want an array of ints. So you can manipulate the array using a pointer to a pointer, just like you'd manipulate an int array using a pointer to int.

A pointer is just a variable, like any other. You want the same ability to manipulate that variable type that you would any other type.

No, it wouldn't shift it by one byte, it would shift it by the size of one float (which would be more than 1 byte, but defined by the implementation). You might want to read up on pointer arithmetic.

It would be a silly thing to do in the case where your pointer points to a single float. On the other hand, it would be a perfectly normal thing to do if your pointer pointed to the first float in an array.