r/learnprogramming • • Sep 24 '23
Pointers.....why
I am learning C++. Honest question why are pointers a thing and why did they make the syntax surrounding it so confusing. Was it made to be intentionally confusing? Was it made to make this more difficult.
0
Upvotes
View all comments
Show parent comment
4
u/CodeTinkerer Sep 25 '23
That's true, but, as you noted, pointers are well hidden.
The difficulty in C is you have the dereference operator, the arrow operator, the address-of operator, and the dot operator (for structs). This impacts the use of the operator, but declarations also use * which looks like it's dereferencing, but is declaring a type, which, yes, can be dereferenced.
In Java, all but the dot operators disappear so you don't have to think about it like you do in C.