Hi!
The examples you listed could be seen as minor usages for pointers.
The real thing comes into the picture with dynamic memory allocation - allocation of memory on the heap.
When you declare a variable, it will have memory allocated on the stack assigned. As soon as it goes out of scope (for example you leave the function it was declared in) it gets dumped.
When you declare a pointer, no memory gets allocated. It is up to you to allocate memory for the pointer using the
new keyword, which allocates memory on the heap. This memory won't get dumped until you tell it to, using the
delete keyword.
Lets see an example. A function that creates a new monster, an instance of the Monster class, which we want to further use in our program.
Without using dynamic allocation:
Monster createMonster(){ Monster m(/*parameters*/); return m; // we try to keep our new monster from getting dumped, so we return it}
We have successfully kept the monster we created, however we had to copy him in order to do so (and we'll probably have to copy him again and again later on), which depending on the complexity of the Monster class could be a significant overhead.
With dynamic allocation:
Monster* createMonster(){ Monster* m = new Monster(/*parameters*/); return m;}
We allocated our monster on the heap, so the only thing we have to return (and thus copy) is our pointer that points to his location in memory. We can pass around this pointer as we please, our monster won't get dumped. With power comes responsibility though: we have to remember to delete our monster when we don't need it anymore.
This came out a little long winded, but hope it sheds some light on the subject.