I was reading Programming Interactivity and they started getting into pointers and references and how to use them. I am a complete beginner and this was pretty intense for me. Read it several times and still don’t understand their examples, but I can see it’s important because it might cause performance issues later, which is no good.
anyway, anyone have a good reference for learning more about these and their applications? need something very beginner-esk
Just for the record: I rewrote that whole section in the new edition of Programming Interactivity New examples and much more explanation.
One of the things I found useful when I first started working with pointers is to make sure that you know where they are all the time, i.e. that a classs contains them, so you know where to go when you need to delete them.
Another really important thing is the difference between delete[] and delete.
foo *p = new foo();
...
delete p;
foo *p = new foo[3];
...
delete[] p;
My rule of thumb is: use references when you just want to modify something somewhere else, use pointers when you want to dynamically create something and not have it be confined to one place (which is less often that you think tbh).
I think the part that really confuses me is that does one actually just store the location and the other stores the object or value? this is where I got confused.