Not at all eh, pointers can be a real headache at first.
btw if you wanna start playing around with them, my best advice is:
don't be confused by the two different meanings of *
it is used to declare a pointer:
int * a_pointer;
and also to "de-reference" a pointer:
1 2 3
|
int a_number;
a_pointer = &a_number;
*a_pointer = 4;
|
the * in the second example means like "variable pointed to by"
so in this example the last line assigns a value of 4 to the
integer pointed to by a_pointer.
more complete code:
1 2 3 4 5 6
|
int a_number; // declare an integer
int * a_pointer; // declare a pointer to an integer
a_pointer = &a_number; // assign a (reference to a_number) to a_pointer
*a_pointer = 4; // assign value of 4 to integer pointed to by a_pointer (which is a_number)
cout << *a_pointer; // print integer pointed to by a_pointer
cout << a_number; // see? it's the same kinda
|
I put those bolds there to translate the * and & in each line..
notice how the * in the second line means something totally different than the * in all the subsequent lines..
in the second usage, you can see how '*' is like opposite of '&' in a way..
I hope that helps to make more sense and not confuse lol sometimes I'm not the most concise