While I agree that reference counting is like mana from heaven, I also see some validity to working with and deeply understanding raw pointers before using reference counting. My reasoning is that without experiencing the hardships that one is bound to encounter using raw pointers, they may not fully understand
why reference counting is a boon, and I for one hate being told "do this because it's correct". Learning the hard way, when it's not life-threatening, can be an educational experience.
The_Technomancer said:
My knowledge of pointers is pretty rudimentary, but then again I think they are rudimentary, aren't they? They're literally just addresses. When I had the workings of a linked list or how to use one as an iterator through something like a vector explained to me I got the concept straight away.
My main issues so far have been learning all the specific syntax and how it interacts (the various different contexts for . :: and ->). Still not entirely comfortable with double pointers, but I haven't worked with them much.
Maybe I can help you on your quest to conquering pointers:
Like you said, a pointer's value is just a location in memory. When we are dealing with a double (or triple, etc) pointer, we are declaring that the address of the double pointer is where we will find yet
another pointer. This second pointer, in turn, locates the data type we are expecting.
For example:
Code:
int (argc, char** argv) { ... }
I'm sure you've seen this before. argc and argv are working in tandem to provide a useful structure. We know that argv is a pointer to a pointer to a char, or in other words, a pointer to a string.
Code:
argv (char**)---+
|
v
char *
|
v
char,char,...,NULL
However, we are only able to assume that there are multiple characters strung together to make a string because we know that (char)0 is the NULL character, which marks the end of the string.
What about if argv? Well, it may contain multiple strings in the same way the char* may contain multiple chars. This is where argc comes in. It, quite simply, tells us just how many char* we should expect in argv. In the case where no arguments are passed into the command line, argc will equal 1, containing just the absolute path to the command called.
If argc > 1, we can expect argv to instead look more like this:
Code:
argv (char**)---+------------------+------------------+------- (and so on)
| | |
v v v
char * char * char *
| | |
v v v
char,char,...,NULL char,char,...,NULL char,char,...,NULL
Hope this helps.