First, be patient, take your time, and read as much as you can. There are lots of good discussions and documents online explaining the complexities of pointers. Pointers can be a difficult subject - I avoided them like the plague when I first learned C - but it's important to know them well. What you want to avoid is what one of my professors termed "Ninja coding": "If it doesn't compile, just throw a star at it". That causes confusion and chaos wherever you turn.
Quote:
Originally Posted by ctccromer
P.S. Why are there references? They're just half-pointers.. Why not use pointers when you'd use references and have one less thing to remember?
|
References are really useful when you get into object-oriented programming, particularly when overloading operators (be patient, you'll get to this eventually). In short, they allow you to make functions that look and feel like pass-by-value without the overhead of actually doing a full copy. Do they do anything you couldn't do with pointers? No, but just like array bracket notation, they make some things more natural.
Now back to debugging a pointer bug in my homework...