+ 2
Why would someone use a pointer?
I am a novice programming and I am currently learning C++. Most of what I have learned (variables, conditional statements, vectors, arrays, structs and by extension classes) immediately shows how and when they can be used. However, pointers currently seems like another aspect of C++ that can be ignored entirely. This is definitely not the case, so when, where, and how would an adept programmer use a pointer.
13 Respostas
+ 4
Imagine working on parking service where you should show people where are empty parking spots. At one point you would be pointing your finger at one position, next time another. In this case your finger is pointer.
This is how I understood pointers when I started studying it at start
+ 2
Thank you for your insight, it is really helpful and appreciated
+ 1
An easy tu understand example I know about is when you want to modify the direct value of a variable, vector, list, etc... in a function, take this code as an example:
https://code.sololearn.com/c0AO2xjBstN7/?ref=app
+ 1
That's the only useful case I know of
+ 1
Check difference between - call by value and call by reference.
Hope this will help u in understanding the use of pointers...!!!
0
Thank you. That shows one example of using a pointer, but I am also curious as to other examples as well.
0
Thank you Kuri
0
That explains the importance of pointers quite a lot, thank you Edin.
0
Hello ...people I still don't understand?