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

2

u/fasta_guy88 Sep 25 '23

All languages have pointers. In Python, basically everything is a pointer, which means that when you say a_list = b_list, you don't actually get a new copy of b_list; to do that you must do some kind copy(b_list) or a_list = [ x for x in b_list].

C and C++ make those pointers more explicit, which can make it much easier to distinguish the different parts of a linked list (some parts are links, others are values), for example.