Friday, September 28, 2012

Why to use pointers?

char *startOfASeriesOfChars ;

Imagine a very long string like the above.
Is not always possible to pass a copy of your data (above)
but you can always pass the address of where that data begins.

Same reason is, why the object in objective C are pointers.
How easy is to pass a big object as argument?
Obviously is easy if it's a pointer.

Pointers are also called references.
Thus, using the pointer to read data at the address is sometimes called dereferencing pointer.

float *c, *d; // is the correct
float* c, b; // c is pointer to a float, b is float!!

No comments:

Post a Comment