C++ Pointers quick question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

C++ Pointers quick question

I know I'm going to get people in here probably going "This has been asked before, use the search bar" but I want to word my question a specific way so I can hopefully understand the answers. I need to know if I am understanding pointers correctly; So, you can use *p /*p for pointer*/ to "declare" a pointer with NOTHING in it, and then use &v /*v for variable*/ to put something into *p? Kind of like when we are working with For Loop integers using stuff like sum 0; x = 0; and then applying stuff to it later on? (x++, sum+=x for the above example) iirc the purpose of Declaring a variable is to ADD something into it later on. So that's what I'm thinking of when I look at all these complicated examples and explanations of pointers.

11th Sep 2020, 2:45 PM
Criss M
Criss M - avatar
1 Answer
+ 3
Yep, you can either initialize it at declaration, you know like default value. Or you can just declare it without giving any value, so you can later on store values in it. (just like you said)
11th Sep 2020, 2:57 PM
Alaska
Alaska - avatar