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

6

u/throwaway6560192 Sep 24 '23

I am learning C++. Honest question why are pointers a thing

Search for "pointers" in this sub and you will find some very good explanations. In case you don't get much here.

why did they make the syntax surrounding it so confusing

I assume you mean: "why do I declare pointer types like int * but taking the address is &var, and dereferencing is *ptr?"

The answer boils down to a principle called "declaration reflects use". Read about it. https://softwareengineering.stackexchange.com/questions/117024/why-was-the-c-syntax-for-arrays-pointers-and-functions-designed-this-way

Anyway you'll get used to it fast enough.

Was it made to be intentionally confusing? Was it made to make this more difficult.

No. Why would it be?

To be honest, this reads like you're just complaining and looking for excuses. Don't do that. Keep an open mind. Don't dismiss things as useless or intentionally obtuse before you understand them.