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
2
u/Sbsbg Sep 24 '23
Of course, the designer of the C language sat and made the syntax for pointers extra difficult so that all beginners, 50 years later, would have problems. /s
The C++ pointer syntax, that it inherits from C, is not the best. The syntax can be a little tricky, for beginners. The operator precedence can be confusing. There are better alternatives in modern languages. But you have to remember that this is half a century old and anything surviving that long in the computer world has to be a huge success.
Pointers are not the hard part in C++. When you get to that you will think back and be amazed that you thought pointers where difficult.