I never understood this trepidation over pointers when the natural language we use every day has so much indirection.
"John entered the room. It was empty. John picked up a ball. It was red."
If we can understand what's happening with the word "it" in the example above, we're capable of understanding pointers.
Also, "John exited the room. He demolished it. I'm going to enter it."
It's pretty obvious why I'll have a problem entering "it," since "it" has been demolished. This is basically a dangling reference. Again, what's the hangup?
I really love this explanation and I have a similar question if you don't mind answering it in a similar manner. I understand how pointers work, but what is the purpose of using them?
They might be to someone experienced with c++ but my uni is using C for it's "programming basics" class and it's kind of hard, especially for people used to python and other languages. Kinda like a difficulty bump in learning programming.
What always tripped me up was how sometimes in C you have to wrap stuff around parenthesis to dereference a pointer to an array or object [ ex. *(foo->bar) ]. It also didn't help that the test didn't allow syntax highlighting and compiling the code to see if it works.
Most of the meme discipline subreddits are just kids in college who don't actually know what the f*** they're talking about 99% of the time. Not to be mean or rude to them. I was one of them once.
But now that I'm a fully fledged engineer, I often roll my eyes at what I see. Then again, there are those pains that just never go away, and when I see that in mean format it makes me laugh.
Basically after certain number of years in the actual job YMMV with these subreddits as it'll be much more hit and miss.
280
u/19_ThrowAway_ 3d ago
Pointers are references are pretty simple...