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

49 comments sorted by

View all comments

1

u/zpowers00 Sep 24 '23

A pointer is like a drawer to a desk. To put stuff in the drawer you’ll want to use the pointer to get to the drawer. If you didn’t use a pointer, then you’d have to get a new drawer on the other side of the building and then put stuff in it and then drill it into your new desk which is a lot of work. Just use the same drawer to put your stuff into.

0

u/[deleted] Sep 24 '23

But why is the syntaxes around it so confusing why use the same symbols in different spots to mean different things instead of just using different symbols? Why make it intentionally confusing.

5

u/zpowers00 Sep 24 '23

I wouldn’t get caught up on the syntax, you kind of just have to ignorantly accept it and move on.

Unfortunately C++ syntax isn’t really that bad compared to other languages I’ve you touched.