I realize 99% of you think "what the h***…" But please help me to get my head around the this concept of using pointers
. I'm sure my specific question would help lots of newbies.
I understand what pointers ARE and that they are a reference to an adress in memory and that by using the (*) operator you can get the value in that address.
Let's say:
int counter = 10;
int *somePointer = &counter;
Now I have the address in memory of counter
, and I can indirectly point to its value by doing this:
int x = *somePointer;
Which makes x = 10
, right?
But this is the most basic example, and for this case I could use int x = counter;
and get that value, so please explain why pointers really are such an important thing in Objective-C and some other languages... in what case would only a pointer make sense?
Appreciate it.