Παρασκευή, 9 Μαρτίου 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.

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

#:From Objective-C Programming: The Big nerd Ranch Guide

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου